在 AS 3.0 中控制加载的 Swish 动画
我正在开发一个 AS 3.0 包装器来添加一些额外的东西,这些东西必须加载一些旧的和普通的框架来构建 SwishMax 3 动画,然后能够停止它们,播放它们,等等...
这是我的代码
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.events.*;
[SWF(backgroundColor="#ffffff", frameRate="17", width="300", height="250")]
public class SwishMaxWrapper extends Sprite {
function SwishMaxWrapper() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
addChild(loader);
var request:URLRequest = new URLRequest("swishy.swf");
loader.load(request);
}
private function completeHandler(event:Event):void {
var movie:MovieClip = event.target.content;
movie.stop();
}
}
}
: load 按预期工作,但 movie.stop() 没有。怎么了?
I'm developing an AS 3.0 wrapper to add some extra stuff that has to load some old and plain frame to frame SwishMax 3 animations and then be able to stop them, play them, and so...
Here is my code:
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.events.*;
[SWF(backgroundColor="#ffffff", frameRate="17", width="300", height="250")]
public class SwishMaxWrapper extends Sprite {
function SwishMaxWrapper() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
addChild(loader);
var request:URLRequest = new URLRequest("swishy.swf");
loader.load(request);
}
private function completeHandler(event:Event):void {
var movie:MovieClip = event.target.content;
movie.stop();
}
}
}
The animation load works as expected but the movie.stop() doesn't. What is wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我测试了你的代码,它可以在我的机器上运行。我加载的 SWF 的动画位于主时间轴中。 swishy.swf 是否有可能不在主时间轴上的动画?也许动画位于另一个符号中,并且该符号的实例位于舞台上。无论如何,当您在上面的代码中调用 stop() 时,它只是告诉主时间线停止,但舞台上的其他影片剪辑将继续播放。
我想这就是 Simsoft 所指出的。
我使用一个 SWF 测试了您的代码,该 SWF 在舞台上有一个带有动画的符号,并且我遇到了您所描述的问题。我通过修改
completeHandler()
来修复它,如下所示:希望您没有在更深的层中嵌套更多动画。如果是这种情况,您将必须修改它以继续监视每个孩子的孩子并尝试停止他们的时间线。
无论如何,希望有帮助。祝你好运!
I tested your code and it works on my machine. The SWF that I loaded had its animation in the main timeline. Is it possible that the swishy.swf has animation that is not on the main timeline? Perhaps the animation is in another symbol instead, and an instance of that symbol is on the stage. Anyway, when you call stop() in your code above, it's just telling the main timeline to stop, but other movie clips on the stage will keep on going.
I think that's what Simsoft was pointing out.
I tested your code using a SWF that had a symbol on the stage that had animation in it, and I got the problem that you are describing. I fixed it by modifying
completeHandler()
as follows:Hopefully you don't have more animations nested at deeper layers. If that's the case, you'll have to modify this to keep peering into the children of each child and trying to stop their timelines as well.
Anyway, hope that helps. Good luck!
stop() 不是递归的,我认为问题就在这里。
stop() isn't recurive, I think the problem is here.