简体   繁体   English

外部 SWF 到外部 SWF 时间线通信、Flash、AS2

[英]External SWF to External SWF Timeline Communication, Flash, AS2

Flash CS4, AS2闪存 CS4、AS2

I have made an interactive tour.我进行了一次互动游览。 It can be seen here:可以在这里看到:

http://www.92YTribeca.org/Tour click on the bottom image http://www.92YTribeca.org/Tour点击底部图片

Each of the 4 sections are external swf and loaded on level 1. I want a button on one swf (floorplan) to load another swf (facility rentals) AND pinpoint a specific frame on the swf's timeline. 4 个部分中的每一个都是外部 swf 并在级别 1 上加载。我想要一个 swf(平面图)上的按钮来加载另一个 swf(设施租赁)并在 swf 的时间轴上确定特定的帧。

I have tried many different ways, all end up loading the swf at the first frame and ignore the rest of the code talking about the timeline.我尝试了许多不同的方法,最终都在第一帧加载了 swf,而忽略了讨论时间线的其余代码。 I know I could split this swf up into more external swfs and get the result I want, but I would rather use code if I can.我知道我可以将此 swf 拆分为更多外部 swf 并获得我想要的结果,但如果可以,我宁愿使用代码。

Is what I want to do possible?我想做的可能吗? If so, how do I write the code?如果是这样,我该如何编写代码?

Thanks!谢谢!

What you want to do is definitely possible.你想做的事绝对有可能。 You need to wait until the SWF is loaded before you can tell it to go to a specific frame.您需要等到 SWF 加载完毕,然后才能告诉它转到特定帧。 The easiest way to do this is using the MovieClipLoader class.最简单的方法是使用 MovieClipLoader 类。

var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(this);

function onLoadComplete(loadedClip) {
    loadedClip.gotoAndStop(5);
}

loader.loadClip("floorplan.swf", targetClip);

That will load floorplan.swf into the placeholder named "targetClip" and, once it's loaded, have to jump to frame 5.这会将 floorplan.swf 加载到名为“targetClip”的占位符中,一旦加载完毕,就必须跳转到第 5 帧。

For more info, see the MovieClipLoader documentation:有关更多信息,请参阅 MovieClipLoader 文档: http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001993.html http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001993.html

Since you manage to load them in perfectly I guess that's not the issue.由于您设法完美地加载它们,我想这不是问题。 A common issue is that you need to call the "gotoAndStop" function when the clip is fully loaded, you will do that when the onLoadInit handler of the MovieClipLoader listener is invoked.一个常见的问题是您需要在剪辑完全加载时调用“gotoAndStop”函数,当调用MovieClipLoader侦听器的onLoadInit处理程序时,您将执行此操作。

Try this:试试这个:

var MC1:MovieClipLoader = new MovieClipLoader();
MClistener = new Object();
MClistener.onLoadComplete = function() {
     trace("LOADED COMPLETED");
};    
MC1.addListener(MClistener); 
MC1.loadClip("Whatever.swf", "adLoader");

I have been looking to communicate between root swf and loaded swf for a while, and this was very useful.我一直在寻找根 swf 和加载的 swf 之间的通信,这非常有用。

var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(this);
function onLoadComplete(loadedClip) {
  loadedClip.gotoAndStop(2);
}
loader.loadClip("chapter1.swf", targetClip);

The only thing I cant figure out is how to make a on(press) action the communication to frame two of the loaded swf instead of the onLoadComplete action.我唯一无法弄清楚的是如何使 on(press) 动作与加载的 swf 的两个框架进行通信,而不是onLoadComplete动作。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM