使用外部 swf 中的事件加载新的外部 swf

发布于 2024-08-27 01:04:32 字数 1395 浏览 7 评论 0原文

我试图在另一个外部 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以畏孤独 2024-09-03 01:04:32

这里可能存在几个问题,但一个非常明显的问题是您似乎没有在正确的位置添加侦听器。

如果您有 A.swf 并且想要侦听加载的 B.swf 的时间线,则需要将侦听器直接添加到时间线,而不是任何容器或加载器,除非您“冒泡”事件。

A.swf

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoaded);
loader.load( new URLRequest("B.swf"))

function onSWFLoaded(e:Event):void
{
    var loaderInfo:LoaderInfo = e.target as LoaderInfo;

    // cleanup the expired event listener
    loaderInfo.removeEventListener(Event.COMPLETE, onSWFLoaded);

    // since the SWF is now loaded you can add a listener to it's timeline ('content')
    loaderInfo.content.addEventListener("VideoComplete", onVideoComplete);

function onVideoComplete(e:Event):void
{
    // do something here ; )
}

B.swf

   // ... your code ...

    video.addEventListener(VideoEvent.COMPLETE, onVideoComplete);

    function onVideoComplete(e:Event):void
    {
         // Notifies A.swf that the playback is finished ("VideoComplete" is just custom event, up to you to improve ...)
         dispatchEvent(new Event("VideoComplete"));
    }

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

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoaded);
loader.load( new URLRequest("B.swf"))

function onSWFLoaded(e:Event):void
{
    var loaderInfo:LoaderInfo = e.target as LoaderInfo;

    // cleanup the expired event listener
    loaderInfo.removeEventListener(Event.COMPLETE, onSWFLoaded);

    // since the SWF is now loaded you can add a listener to it's timeline ('content')
    loaderInfo.content.addEventListener("VideoComplete", onVideoComplete);

function onVideoComplete(e:Event):void
{
    // do something here ; )
}

B.swf

   // ... your code ...

    video.addEventListener(VideoEvent.COMPLETE, onVideoComplete);

    function onVideoComplete(e:Event):void
    {
         // Notifies A.swf that the playback is finished ("VideoComplete" is just custom event, up to you to improve ...)
         dispatchEvent(new Event("VideoComplete"));
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文