how do I link a button inside a movie clip into the mainframe (flash CS6 AS3)

穿精又带淫゛_ 提交于 2019-12-13 05:44:57

问题


i have made a movie clip with some buttons inside. The idea behind this was to allow a scrolling system to be used. The only problem is i can't seem to figure out how to link a button inside a movie clip with a frame from outside of the movie clip and on the main stage.

My code atm is:

stop();
import flash.events.MouseEvent;

sports1.addEventListener(MouseEvent.CLICK,sport1)

function sport1(e:MouseEvent)

{
    MovieClip(root).gotoAndStop(sports)
}

What i would like to happen is that each button inside the movie clip will take me to a certain frame on the main stage, like a navigation system. I am really new to flash so i may not understand all the technical terms yet, so be easy on me :)


回答1:


So if you are creating a Main Movie Clip on the Stage and have inner Movie Clips that are acting as buttons. You want those inner buttons to take you to different frames on the main stage when the user interacts with them.

This is how you would do so.

What you would need to do as you already done give the Main Movie clip holding the inner buttons an instance name sports1 any inner button would also need an instance name say a button has an instance name of mcButton to access that button you would need to call on it like so:

sports1.mcButton.addEventListener(MouseEvent.CLICK,sport1)
sports1.mcButton.buttonMode = true;

then if you want that button when clicked to go to frame 2 on the main stage you would simply do this in the sport1function:

function sport1(e:MouseEvent):void 
{
      gotoAndStop(2);
}

I threw in the sports1.mcButton.buttonMode = true; that way it shows that it is interactive ie click able



来源:https://stackoverflow.com/questions/28995461/how-do-i-link-a-button-inside-a-movie-clip-into-the-mainframe-flash-cs6-as3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!