开发者

Flash: Play a movieclip then go to a different frame for each buttons

I have 10 buttons on my homepage and I want to play the same movieclip when you click on a button and after that move to a specific frame for each different button.

Someone know an easy to make开发者_运维技巧 this without having to create 10 differents movieclips just to change the action at the end of the movieclip?

Thank you


This is a fairly easy way of doing it: Make sure your buttons is present in the timeline when the script executes.

button1.addEventListener(MouseEvent.CLICK, onClickHandler);
button2.addEventListener(MouseEvent.CLICK, onClickHandler);
button3.addEventListener(MouseEvent.CLICK, onClickHandler);

private function onClickHandler(event : MouseEvent) : void
{
    switch(event.target)
    {
        case button1:
            // code to execute when button 1 is clicked
            gotoAndPlay(50);
            break;

        case button2:
            // code to execute when button 2 is clicked
            gotoAndPlay(100);
            break;

        case button3:
            // code to execute when button 3 is clicked
            gotoAndPlay(150);
            break;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜