简体   繁体   English

AS3从AN外部加载的SWF中加载外部SWF-正在访问儿童吗?

[英]AS3 Loading external swf from AN externally loaded swf - Accessing Children?

EDIT 编辑

UPDATE MARCH 12TH 2012: This is done using AIR FOR ANDROID USING CS5.5. 2012年3月12日更新:使用CS5.5使用AIR FOR ANDROID完成。 I need access to the vars in the newly EXTERNALLY LOADED SWF files that are hosted on a web server and I need to have the APP on my phone access them. 我需要访问Web服务器上托管的新外部加载的SWF文件中的var,并且需要手机上的APP可以访问它们。 I am beginning to this is not possible. 我开始这是不可能的。

------------------------------------------------------------------------------ -------------------------------------------------- ----------------------------

My Main Stage swf loads another one: 我的主舞台瑞士法郎加载另一个:

SWF 1 SWF 1

var TheContent:Loader = new Loader();
    TheContent.load(new URLRequest("http://MyWebsite.com/swf2.swf"));

/// In this SWF 1 above I NEED TO KNOW WHAT CODE can see if other content is loaded and control it when loaded. ///在上面的SWF 1中我需要知道什么代码可以查看是否已加载其他内容并在加载时对其进行控制。 But its tricky because I am loading external content from an externally loaded swf. 但这棘手,因为我要从外部加载的swf加载外部内容。

Here is the code in SWF 2 这是SWF 2中的代码

var TheMenu:Loader = new Loader();
TheMenu.load(new URLRequest("http://MyWebsite.com/MenuBar.png")); // you were missing a "

In the first SWF 1 I want to know if the MenuBar.png has loaded and how to control it. 在第一个SWF 1中,我想知道MenuBar.png是否已加载以及如何对其进行控制。 So for example in SWF 1 I might put code like this... 因此,例如在SWF 1中,我可能会这样输入代码...

    if(TheContent.MenuBar) /// IS LOADED? THEN...
    {
        MenuBar.alpha = .3;
        MenuBar.x = 33;
        etc...
    }

You can save the progress value into a public variable, that can be acessed through the swf. 您可以将进度值保存到公共变量中,可以通过swf进行访问。

The follow code for SWF 2: 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;
    }
}`

The follow code for SWF 1: SWF 1的以下代码:

public function printStatus():void{

        //Returs file`s progress
        trace("Progresss: "+swf1.fileProgress);

        //Return file`s size
        trace("File size: "+swf1.fileTotalBytes);
    }

I hope this can help you! 希望对您有所帮助!

First Point, it seems that your whole structure is proberly not the best approach. 首先,似乎您的整个结构不是最好的方法。 From my under standing your question is: 根据我的理解,您的问题是:

(Main Movie) loads secondary(Movie) then (SECONDARY) Movie loads its secondary (movie); (主电影)加载次要(电影)然后(SECONDARY)电影加载次要(电影);

then you want the first movie to control the second movie on condition the third movie is %100 and ready for action 那么您希望第一部电影控制第二部电影,条件是第三部电影是%100并准备采取行动

This will target from the loaded Swf to the main SWF 这将从加载的Swf定位到主SWF

      MovieClip(parent.parent).ParentFunction();    // or the 3rd movie would be 
      MovieClip(parent.parent.parent).ParentFunction();

I have made you a file on my server http://www.gamezslave.net/SampleAS3/ 我已经在我的服务器上为您创建了文件http://www.gamezslave.net/SampleAS3/

Just open the main movie.swf you will see it load the other two movies inside of each other as you wanted then it plays an animation in the first movie to let you know the 3rd movie has finished downloading. 只需打开main movie.swf,您将看到它根据需要将其他两部电影相互加载,然后在第一部电影中播放动画,让您知道第三部电影已完成下载。 Let me know how you go please as i took 15 minutes putting it together for you. 我花了15分钟的时间为您整理,让我知道你的情况。

in the zip (contains all source files 3x "SWF" and 3x "html pages"); 在zip中(包含所有源文件3x“ SWF”和3x“ html页面”);

thanks BJM Sydney 感谢BJM悉尼

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

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