1
votes

EDIT

UPDATE MARCH 12TH 2012: This is done using AIR FOR ANDROID USING CS5.5. 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. I am beginning to this is not possible.

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

My Main Stage swf loads another one:

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. But its tricky because I am loading external content from an externally loaded swf.

Here is the code in 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. So for example in SWF 1 I might put code like this...

    if(TheContent.MenuBar) /// IS LOADED? THEN...
    {
        MenuBar.alpha = .3;
        MenuBar.x = 33;
        etc...
    }
2
I don't have time to try this out and post a real answer ATM but look into adding event listeners to the loaderInfo object that belongs to your Document Class, or the root container object for your application. Some more nfo on working with this object can be found at: stackoverflow.com/questions/3315904/… and help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/…. It's only a theory but, it might be possibly to globally intercept all LOADED events through this object.user562566

2 Answers

0
votes

You can save the progress value into a public variable, that can be acessed through the swf.

The follow code for 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:

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!

0
votes

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);

then you want the first movie to control the second movie on condition the third movie is %100 and ready for action

This will target from the loaded Swf to the main 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/

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. Let me know how you go please as i took 15 minutes putting it together for you.

in the zip (contains all source files 3x "SWF" and 3x "html pages");

thanks BJM Sydney