How do I play movie clip when you click on button
I am new to flash....Here's what I am trying to do. I working on the timeline and have some Actionscript 3 code (I have a actions layer on the timeline). I am not sure what the code is fo开发者_高级运维r clicking on a button(I made the buttons movie clips since I wanted to animate it) and it plays a movie clip. Any help would be appreciated! Thanks
Assuming you have one button (movieclip) named "myButton" and one movieclip named "targetMc" on stage you can do it like this:
myButton.buttonMode = true; // set the movieclip to act as a button
myButton.addEventListener(MouseEvent.CLICK, onButtonClick); // add mouse listener
function onButtonClick(event : Event) : void
{
trace("clicked" + event.target);
//gotoAndPlay("someFrameLabel"); // plays frame in current timeline
targetMc.gotoAndPlay("someFrameLabel"); // plays frame in instance "targetMc" timeline
}
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d9d.html
refer this.
精彩评论