Reputation: 7
I am working on a little AS3 game and am a bit stuck.
I am trying to use a button to 'advance' or rather, move the focus along the timeline within a separate, root level MovieClip ('score_mc') ... e.g. frame one to two, two to three etc.
However, I have 25 MovieClips which have buttons in them - but I ONLY want those buttons to be able to effect the 'score_mc' once. So, effectively, I want to 'lock out' the 'advance' effect after it's been done once per button click.
ps I need to be able to use the buttons over and over again, but only effecting the 'score_mc' the first time each one is used.
Is there a simple way of doing this?
Upvotes: 0
Views: 80
Reputation: 133
I recommend setting a boolean var to do this for each button? something like firstClick = true
at instantiation, but flipping it to false
in the onPress
method?
Something like:
function click_handler(event:MouseEvent):void {
if (this.firstClick) {
score_mc.nextFrame();
this.firstClick = false;
}
}
my_button.addEventListener(MouseEvent.CLICK, click_handler);
Upvotes: 1
Reputation: 512
Just define an array of boolean, size of 25, on the click event function, check when the array[i] == false, then forward the score_mc, and mark the array[i] = true
Upvotes: 1