Reputation: 55
In my flash file, I have three buttons. And I need to control three movie clips respectively with each button. However, when I test it, just right after test window has been initialized, all three movie clips playing automatically without me clicking the button. Here is my code:
dropper_button1.addEventListener(MouseEvent.CLICK, dropper1);
function dropper1 (event:MouseEvent):void{
reaction_clip1.play();
}
dropper_button2.addEventListener(MouseEvent.CLICK, dropper2);
function dropper2 (event:MouseEvent):void{
reaction_clip2.play();
}
dropper_button3.addEventListener(MouseEvent.CLICK, dropper3);
function dropper3 (event:MouseEvent):void{
reaction_clip3.play();
}
I'm not sure where my code got wrong. Any advice would be great. Thank you!!!
Upvotes: 0
Views: 712
Reputation: 1285
the movieclips must have stop(); on frame 1.. you can do it in your fla or in your code like this in your first lines:
reaction_clip1.stop();
reaction_clip2.stop();
reaction_clip3.stop();
Upvotes: 1
Reputation: 12431
You need to explicitly stop the MovieClips
as they will play by default. You can do this by adding a stop()
to the first frame of each MovieClip
, or you could stop each one in the frame where you set up your listeners:
reaction_clip1.stop();
reaction_clip2.stop();
reaction_clip3.stop();
dropper_button1.addEventListener(MouseEvent.CLICK, dropper1);
function dropper1 (event:MouseEvent):void{
reaction_clip1.play();
}
dropper_button2.addEventListener(MouseEvent.CLICK, dropper2);
function dropper2 (event:MouseEvent):void{
reaction_clip2.play();
}
dropper_button3.addEventListener(MouseEvent.CLICK, dropper3);
function dropper3 (event:MouseEvent):void{
reaction_clip3.play();
}
Upvotes: 0