简体   繁体   English

如何将影片剪辑内的按钮链接到大型机(Flash CS6 AS3)

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

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: 我的代码atm是:

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 :) 我真的是新手,所以我可能还不了解所有技术术语,所以对我来说很容易:)

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: 完成后需要执行的操作为拥有内部按钮的Main Movie剪辑提供一个实例名称sports1任何内部按钮也都需要一个实例名称,例如,一个按钮的实例名称为mcButton即可访问该按钮像这样:

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 sport1 function: 然后,如果您想在主舞台上单击该按钮以转到第2帧,则只需在sport1函数中执行以下操作:

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

I threw in the sports1.mcButton.buttonMode = true; 我扔了sports1.mcButton.buttonMode = true; that way it shows that it is interactive ie click able 这样就表明它是交互式的,即可以点击

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM