使用外部 swf 中的事件加载新的外部 swf
我试图在另一个外部 swf 的 flv 内容播放完毕时加载外部 swf。
我只使用了 actioscript 3 大约一周,而且我是通过教程了解到这一点的,所以我的知识是有限的。
这是我到目前为止所得到的:
外部 swf 代码(带有 flv 内容):
import fl.video.FLVPlayback;
import fl.video.VideoEvent;
motionClip.playPauseButton = player;
motionClip.seekBar = seeker;
motionClip.addEventListener(VideoEvent.COMPLETE, goNext);
function goNext(e:VideoEvent):void {
nextFrame();
}
这是主文件的代码:
var Xpos:Number=110;
var Ypos:Number=110;
var swf_MC:MovieClip = new MovieClip();
var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest("arch_reel.swf");
addChild (swf_MC);
swf_MC.x=Xpos
swf_MC.y=Ypos
loader.load(defaultSWF);
swf_MC.addChild(loader);
//Btns Universal Function
function btnClick(event:MouseEvent):void{
SoundMixer.stopAll();
swf_MC.removeChild(loader);
var newSWFRequest:URLRequest = new URLRequest("motion.swf");
loader.load(newSWFRequest);
swf_MC.addChild(loader);
}
function returnSWF(event:Event):void{
swf_MC.removeChild(loader);
loader.load(defaultSWF);
swf_MC.addChild(loader);
}
//Btn Listeners
motion.addEventListener(MouseEvent.CLICK,btnClick);
swf_MC.addEventListener(swf_MC.motionClip.Event.COMPLETE,swf_MC.motionClip.eventClip, returnSWF);
我开始了解所有这些是如何工作的,但这都是新的目前对我来说,所以我确信我从错误的角度来处理它。
任何帮助都会很棒,因为我已经尝试了几天了。
谢谢
I'm trying to get an external swf to load when the flv content of another external swf finishes playing.
I've only been using actiosncript 3 for about a week and I've got to this point from tutorials, so my knowledge is limited.
This is what I've got so far:
Code for External swf (with flv content):
import fl.video.FLVPlayback;
import fl.video.VideoEvent;
motionClip.playPauseButton = player;
motionClip.seekBar = seeker;
motionClip.addEventListener(VideoEvent.COMPLETE, goNext);
function goNext(e:VideoEvent):void {
nextFrame();
}
And this is the code for the main file:
var Xpos:Number=110;
var Ypos:Number=110;
var swf_MC:MovieClip = new MovieClip();
var loader:Loader = new Loader();
var defaultSWF:URLRequest = new URLRequest("arch_reel.swf");
addChild (swf_MC);
swf_MC.x=Xpos
swf_MC.y=Ypos
loader.load(defaultSWF);
swf_MC.addChild(loader);
//Btns Universal Function
function btnClick(event:MouseEvent):void{
SoundMixer.stopAll();
swf_MC.removeChild(loader);
var newSWFRequest:URLRequest = new URLRequest("motion.swf");
loader.load(newSWFRequest);
swf_MC.addChild(loader);
}
function returnSWF(event:Event):void{
swf_MC.removeChild(loader);
loader.load(defaultSWF);
swf_MC.addChild(loader);
}
//Btn Listeners
motion.addEventListener(MouseEvent.CLICK,btnClick);
swf_MC.addEventListener(swf_MC.motionClip.Event.COMPLETE,swf_MC.motionClip.eventClip, returnSWF);
I'm starting to get an understanding of how all of this works, but it's all to new to me at the moment, so I'm sure I've approached it from the wrong angle.
Any help would be fantastic, as I've been trying at this for a few days now.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里可能存在几个问题,但一个非常明显的问题是您似乎没有在正确的位置添加侦听器。
如果您有 A.swf 并且想要侦听加载的 B.swf 的时间线,则需要将侦听器直接添加到时间线,而不是任何容器或加载器,除非您“冒泡”事件。
A.swf
B.swf
There's probably several issues here but one quite obvious is that you don't seem to add the listener at the right place.
If you have A.swf and want to listent to the loaded B.swf's timeline you need to add the listener to directly to the timeline and not to any container or loader unless you 'bubble' the event up.
A.swf
B.swf