A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: how to make a button can be used once only

Hybrid View

  1. #1
    Junior Member
    Join Date
    Nov 2005
    Posts
    2

    how to make a button can be used once only

    hello,

    i would like to know how to make a button to be used once only. for example, i made a button and it'll add score when i press it. i only want it to score once, but since i used a on(release), so it'll continue to add score when i keep clicking it. is there a way to make it happen once only?
    here is the actionscrpit that i'm using.

    on (release) {
    _root.score += 100;
    }

    please help me!

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    on the first frame of the timeline put this code in the actions layer.

    var scorepressed = false;

    then in the button:
    on (release) {
    if(_root.scorepressed == false){
    _root.score += 100;
    }
    scorepressed = true;
    }

  3. #3
    Senior Member
    Join Date
    Oct 2004
    Location
    Rio de Janeiro, Brazil
    Posts
    344
    Give to the button a name, say myButton.
    Then disable it as soon it is pressed:

    on (release)
    {
    myButton.enabled = false;
    _root.score += 100;
    }

    You will just get it pressed once...

  4. #4
    Junior Member
    Join Date
    Nov 2005
    Posts
    2
    it works!!! thank you so much!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center