我有一个从 MovieClip 扩展的自定义类。该类基本上创建一个按钮,该按钮使用 MovieClip 中的帧标签在调度鼠标事件时在按钮状态之间移动。每个状态(每个状态大约 20 帧长)都以时间线 stop()
终止。
该类已在许多其他项目中使用,但在我当前应用程序中的某个点之后,作为按钮类的扩展创建的任何按钮都会停止执行时间轴上的代码,而只是循环播放。这包括放入时间线中的任何跟踪,但类中的所有代码仍然正确执行,甚至在按钮状态更改时调用 gotoAndPlay。
最奇怪的部分是舞台上任何行为不当的按钮实例都不会引发错误。
我需要的是关于什么可以阻止任何扩展某个类的对象执行时间线代码而不引发错误的建议。
谢谢!
更新:这仍然让我感到困惑。我们的项目通常分为三个部分:轻量级预加载器、语言和年龄门,然后是主要应用程序。每个都加载到前一个中,每次都使用当前应用程序域。加载主应用程序后,任何扩展 MovieClip(直接或间接)的自定义显示对象都将忽略直接在其时间轴上的任何动作脚本。然而,播放头仍然可以通过类进行控制。
更新2:这是我制作的测试按钮类中的代码。请注意,里面什么也没有。
package com.test
{
import flash.display.MovieClip;
public class TestLabelButton extends MovieClip
{
public function TestLabelButton():void
{
}
}
}
更新3:所以我缩小了范围,但这很奇怪。看来我可以将我的语言门加载到预加载器中,语言门是一个带有扩展 MovieClip 的自定义文档类的 swf。不过,在那之后,如果我加载更多包含扩展 MovieClip 的自定义文档类的 SWF,就像其扩展的所有后续实例化 MovieClip 都会丢失其时间线上的所有代码一样。
I have a custom class that is extended from MovieClip. The class is basically creating a button that uses frame labels in the MovieClip to move between button states as mouse events are dispatched. Each state (each approx 20 frames long) is terminated with a timeline stop()
.
This class has been used in numerous other projects, but after a certain point in my current application any buttons created as an extension of my button class stop executing the code on the timeline, and just play on a loop. This includes any traces put into the timeline, but all code in the class still executes correctly, even the gotoAndPlay calls when the button state changes.
The strangest part is that no error is thrown by any of the misbehaving button instances on the stage.
What I need are suggestions of what could prevent any object that extends a certain class from executing timeline code without throwing an error.
Thanks!
UPDATE: This still has me stumped. Our projects usually come in three parts: a lightweight preloader, a language and age gate, then the main application. Each is loaded into the previous, each time using the current application domain. After the main application has been loaded, any custom display object that extends MovieClip (directly or indirectly) will ignore any actionscript directly on its timeline. The playhead can still be controlled though the class however.
UPDATE 2: This is the code in the test button class that I have made. Notice how there is nothing in it.
package com.test
{
import flash.display.MovieClip;
public class TestLabelButton extends MovieClip
{
public function TestLabelButton():void
{
}
}
}
Update 3: So I've narrowed it down, but it's strange. It seems that I can load my language gate into the preloader just fine, with the language gate being an swf with a custom document class that extends MovieClip. After that though, if I load any more SWFs that contain a custom doc class extending MovieClip it's like all subsequently instantiated MovieClips of extentions thereof loose all the code on their timelines.
发布评论
评论(4)
根据您的描述,这听起来像是在 FlashIDE 中运行 SWF 时出现编译错误。
它只会循环遍历所有帧。
我相信您在正常的闪光灯按钮闪烁之前已经见过它。
您是否尝试过将有问题的 MovieClip 单独放入一个新项目中,看看会发生什么?
From what you describe it sounds like when you run a SWF in the FlashIDE with compile errors.
It will just loop though all the frames.
I am sure you have seen it before normal flash buttons just flicker.
Have you tried to take the offending MovieClip and put it in a new project alone and see what happens?
我不确定我完全理解你的问题,但这听起来对我过去遇到的问题非常熟悉。我也做同样的事情。我从不使用按钮符号,总是选择使用影片剪辑,因为它们更灵活,并且所有按钮状态动画立即公开,我找到了一种更直观的工作方式。
无论如何,请确保您通过框架标签/名称调用的任何框架在该框架上都没有
stop()
。我已经犯过几次这样的错误,在翻转动画开始时有一个 fRollOver 帧标签,而当您gotoAndPlay("fRollOver")
时,它什么也不做。我发现的另一件事是,如果您在第一帧上立即使用
stop()
,有时事情会刹车,而且我已经经历过很多次了。 Flash 有时只是不喜欢它,我无法解释这一点。它确实适用于我的几乎所有项目。可能是Flash版本问题。I'm not sure I fully understand your issue, but this sounds incredibly familiar to a problem I had in the past. I do the same thing. I never use Button symbols and always opt to use a MovieClip instead, since they're more flexible and having all your button state animations immediately exposed I find a much more intuitive way of working.
Any way, make sure that whatever frame you're calling via a frame label / name doesn't have a
stop()
on that frame. I've made that mistake a couple of times, where I have a fRollOver frame label at the start of a rollOver animation, and when yougotoAndPlay("fRollOver")
, it just does nothing.Another thing I've found is, and I've experienced this numerous times, that if you have a
stop()
immediately on the first frame, sometimes things brake. Flash just doesn't like it sometimes, and I can't explain this. It certainly works on almost all my projects. It might be a Flash version issue.我的建议是设计你的影片剪辑按钮,使状态所需的任何动画都发生在它们自己的剪辑中,并具有它们自己的循环时间线。换句话说,按钮的每个“状态”在按钮剪辑事物的时间轴上都有一帧——而不是在主时间轴上进行普通的播放或循环。所有播放头控制都在您的外部类中,并且仅包含 *gotoAndStop* 来控制主时间轴,并可能包含 stop() 和 play() 命令来启动和停止动画剪辑的时间轴在每个按钮状态框架上。
最重要的是,不要尝试从多个位置控制任何剪辑的播放头,因为这样做会引发奇怪的、通常难以重现的控制冲突错误。
此外,帧脚本中的错误将阻止 Flash Player 在该剪辑上执行帧脚本。您是否收到编译时错误或警告?
My recommendation is to design your movieclip button thing in such a way that any animations needed for the states are happening in their own clips, with their own looping timelines. In other words, each "state" of your button has one frame on the timeline of your button clip thing--no ordinary playing or looping on your main timeline. All playback head control is in your external class, and consists only of *gotoAndStop*s to control the main timeline, and possibly stop() and play() commands to start and stop timelines of the animation clips on each button state frame.
Bottom line, don't attempt to control the playback head of any clip from more than one place, because to do so is to invite weird, often hard-to-reproduce control conflict bugs.
Also, an error in your frame script will stop the Flash Player from executing frame scripts on that clip. Are you getting compile-time errors or warnings?
我相信 The_asMan 走在正确的道路上。我相信您要么遇到了导致此问题的运行时错误,要么您已经设法使用 flash IDE 构建了对象继承,从而基本上在 MovieClip 类上进行了“原型化”。如果您曾经使用过 AS2 或 AS1,您就会明白我的意思。由于您的类本质上是空的,所以我倾向于选项 2。我相信您已经以某种方式覆盖了 MovieClip 类或使用 Flash UI 对其进行了原型设计。
或者
您错误地构建了对象,并在设计时在舞台上放置了多个实例。像这样:
当然问题是,而不是使这个库对象成为您的自定义类型的类类,具有唯一标识符,您只需将此影片剪辑的内容链接到单个类。在这种情况下,使用设计 UI 在舞台上创建多个实例在技术上会产生错误,因此在运行时 Flash 可能会通过将这些对象声明到它们自己的动态生成的类中来自动补偿此错误,这会破坏您在一种反常的方式。执行此操作的正确方法是按原样保留 ActionScript 配置的导出并在代码中创建此类的实例,或者将对象的基类设置为自定义类并为其指定唯一标识符(如果您想设计视图中的布局,示例如下)。
因此,现在 Flash 提前知道您已在设计视图中使用特定基类创建了对象并且知道您想继承它。在上述情况下,字节码到达虚拟机,然后显示“WOA,您需要在舞台上创建 10 个完全相同的类的副本吗?好吧,这行不通,所以在这里让我为您创建一些通用对象,其中包含这些视觉对象”。其中的内容。”不管怎样,我想我在重复自己,所以希望这对你有帮助。只是一个理论。 :)
I believe The_asMan is on the right track. I believe you're either getting a runtime error that's causing this or you've managed to build your object inheritance using the flash IDE in such a way that you've essentially "prototyped" over the MovieClip class. If you were ever an AS2 or AS1 person you'll get what I mean by that. Since your class is essentially empty I'm leaning toward option 2. I believe you've somehow overridden the MovieClip class or prototyped over it using the Flash UI.
OR
You've built out your object wrong and placed multiple instances on the stage at design time. Like this:
The problem of course would be that instead of making this library object a CLASS OF TYPE your custom class, with a unique identifier, you've simply linked the contents of this movie clip to a single class. In this case, creating multiple instances on the stage using the design UI would technically produce errors, so at runtime flash is probably compensating automatically for this mistake by declaring these objects into their own dynamically generated classes, which would blow away all of your functionality in an anomalous way. The proper way to do this would be to either leave your export for actionscript configuration as is and create instances of this class in code, or set the base class of the object to your custom class and give it a unique identifier (if you want to layout in design view, example below).
So now flash knows ahead of time that you've created objects in the design view with a specific base class and knows that you want to inherit from it. In the above condition, the bytecode hits the virtual machine and it goes "WOA, you need 10 copies of the exact same class on the stage? Well that won't work so here let me create some generic objects here for you with those visual contents in them." Anyway I think I'm repeating myself so hopefully this is helpful. Just a theory. :)