[英]AS3 Loading external swf from AN externally loaded swf - Accessing Children?
编辑
我的主舞台瑞士法郎加载另一个:
SWF 1
var TheContent:Loader = new Loader();
TheContent.load(new URLRequest("http://MyWebsite.com/swf2.swf"));
///在上面的SWF 1中 , 我需要知道什么代码可以查看是否已加载其他内容并在加载时对其进行控制。 但这很棘手,因为我要从外部加载的swf加载外部内容。
这是SWF 2中的代码
var TheMenu:Loader = new Loader();
TheMenu.load(new URLRequest("http://MyWebsite.com/MenuBar.png")); // you were missing a "
在第一个SWF 1中,我想知道MenuBar.png是否已加载以及如何对其进行控制。 因此,例如在SWF 1中,我可能会这样输入代码...
if(TheContent.MenuBar) /// IS LOADED? THEN...
{
MenuBar.alpha = .3;
MenuBar.x = 33;
etc...
}
您可以将进度值保存到公共变量中,可以通过swf进行访问。
SWF 2的以下代码:
import flash.display.Loader;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
public class YourClassName
{
/**This will get a progress number of your file**/
public var fileProgress:Number = 0;
/**This will get the file size**/
public var fileTotalBytes:Number = 0;
public function YourClassName()
{
var TheMenu:Loader = new Loader();
TheMenu.addEventListener(ProgressEvent.PROGRESS, onProgressHandler, false, 0, true);
TheMenu.load(new URLRequest("http://MyWebsite.com/MenuBar.png"));
}
protected function onProgressHandler(event:ProgressEvent):void{
fileProgress = event.bytesLoaded;
fileTotalBytes = event.bytesTotal;
}
}`
SWF 1的以下代码:
public function printStatus():void{
//Returs file`s progress
trace("Progresss: "+swf1.fileProgress);
//Return file`s size
trace("File size: "+swf1.fileTotalBytes);
}
希望对您有所帮助!
首先,似乎您的整个结构不是最好的方法。 根据我的理解,您的问题是:
(主电影)加载次要(电影)然后(SECONDARY)电影加载次要(电影);
那么您希望第一部电影控制第二部电影,条件是第三部电影是%100并准备采取行动
这将从加载的Swf定位到主SWF
MovieClip(parent.parent).ParentFunction(); // or the 3rd movie would be
MovieClip(parent.parent.parent).ParentFunction();
我已经在我的服务器上为您创建了文件http://www.gamezslave.net/SampleAS3/
只需打开main movie.swf,您将看到它根据需要将其他两部电影相互加载,然后在第一部电影中播放动画,让您知道第三部电影已完成下载。 我花了15分钟的时间为您整理,让我知道你的情况。
在zip中(包含所有源文件3x“ SWF”和3x“ html页面”);
感谢BJM悉尼
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.