简体   繁体   English

将外部类与时间线上的多个帧和放置在多个阶段的按钮一起使用

[英]Using an external class with multiple frames on the timeline and multiple stage placed buttons

I have a problem when making flash applications with more than one frame that has symbols placed on it in that I can't declare all of the event listeners for the objects at the same time and I have found that even if I put them all on the first frame, add the event listeners, then click through to the next frame then the buttons won't work on that frame. 在制作带有一个以上带有符号的框架的Flash应用程序时,我遇到了一个问题,因为我无法同时声明对象的所有事件监听器,但我发现即使将它们全部放在上面在第一个框架中,添加事件侦听器,然后单击进入下一个框架,然后按钮将无法在该框架上使用。

Does anyone have any idea how I could solve this? 有谁知道如何解决这个问题? I did consider myself a fairly competent AS3 programmer until I realised I had no idea how to handle this sort of thing 我确实认为自己是一个相当称职的AS3程序员,直到我意识到自己不知道如何处理这类事情为止

Solved: I initialised the clips from my external class and then addChild'd and removeChild'd them as I needed to and placed their x and y on addChilding. 解决:我从外部类初始化了片段,然后根据需要添加了addChild'd和removeChild'd并将它们的x和y放在addChilding上。 Thanks, guys 多谢你们

When working both with Flash & an external IDE such as FlashBuilder , I tend to put as little code as possible in Flash and handle most of the logic in FlashBuilder. 当同时使用Flash和外部IDE(例如FlashBuilder)时,我倾向于在Flash中放入尽可能少的代码,并处理FlashBuilder中的大多数逻辑。 Since you refer to an external class , I'm assuming that you may have a similar setup , whereas some of the coding is done outside the Flash IDE. 由于您引用的是外部类,因此我假设您可能具有类似的设置,而某些编码是在Flash IDE外部完成的。

I don't know your project so it may not be possible or it may be a little late to externalize all your code, but this would be my first option. 我不知道您的项目,因此可能无法实现,或者将所有代码外部化可能会有点晚,但这是我的首选。 I find it easier to keep track of the event listeners , the functions triggered , the number of children on stage, who does what when etc... 我发现更容易跟踪事件侦听器,触发的功能,舞台上的孩子人数,谁在什么时候做什么等...

Another way to look at it, could also be to encapsulate your methods in your MovieClips so that they're not frame dependent and use event dispatching to call methods on the main timeline 另一种看待它的方法,也可以将方法封装在MovieClips中,以使它们不依赖于帧,并使用事件分派在主时间轴上调用方法

Well, the better approach will be put all symbols on Frame 1 and add event listener on First Frame OR add them in document class.You can put those symbols outside the stage which are not required to be visible at first Frame and you can bring them on stage on specific frame. 好了,更好的方法是将所有符号放在第1帧上,并在第一帧上添加事件侦听器,或将它们添加到文档类中。在特定框架上的舞台上。

Listeners will be attached to the symbols if they are at first Frame otherwise you will have to attach them on that frame where they are defined and used. 如果侦听器位于符号的第一帧,它们将被附加到符号上,否则您将必须将它们附加在定义和使用符号的那个框架上。 And once, listeners are attached to the buttons or any DisplayObjects then it does not matter, frame changes or not. 并且,一旦将侦听器附加到按钮或任何DisplayObject上,则无所谓,无论帧是否更改。 May be your buttons have changed during frame by frame Animation.. 可能是在逐帧动画过程中您的按钮已更改。

Another way to look at it, could also be to encapsulate your methods in your MovieClips so that they're not frame dependent and use event dispatching to call methods on the main timeline 另一种看待它的方法,也可以将方法封装在MovieClips中,以使它们不依赖于帧,并使用事件分派在主时间轴上调用方法

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

相关问题 如何在动态放置在舞台上的多个实例上使用hitTestObject? (AS3) - How to use hitTestObject on multiple instances dynamically placed on the stage? (AS3) AS3:添加多个按钮以与eventlistener一起登台吗? - AS3: Add multiple buttons to stage with eventlistener? AS2将多个动态文本字段更新为时间轴中的所有帧 - AS2 Update multiple dynamic text fields to all frames in timeline 加载多个外部 swf 并使用子项上的按钮进行导航 - Loading multiple external swf and navigate using buttons on child ActionScript 3.0-检测已经放置在舞台上的多个实例并将其添加到数组中 - Actionscript 3.0 - detecting multiple instances already placed on stage and adding them to an array 从班级访问舞台上的按钮 - Accessing buttons on stage from class 在动作脚本中使用基类对时间轴帧进行的动作 - Actions on timeline frames using baseclass in actionscript 在Flash Pro 2015 HTML5项目中将对象放置在舞台上的时间轴(“ this”)的名称是什么? - What is the name of the timeline (“this”) where objects are placed on the stage in Flash Pro 2015 HTML5 projects? 在舞台上添加多个孩子 - Adding multiple children to the stage 动作3使用ColorPicker沿时间线更改多个对象 - Actionscript 3 Using ColorPicker to change multiple objects along a timeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM