Jump to content
GreenSock

sgershen

Loading external .swf from an array in array order

Recommended Posts

I am new at greensock I wanted to see if someone can help me out with this and see if loadermax can do what I need it to do. Below is as3 code to dynamically load in an external .swf from the same directory

 

the external .swf are named clip0.swf','clip1.swf','clip2.swf

In the main flash i have the as code as followed below.

What I want to accomplish is to load up clip0.swf' dynamically. then when I refresh the page or republish the main file it should show clip1.swf then do it again for clip2.swf. in that order everytime the page refresh the new .swf gets loaded.

 

the below code randomizes these flashes & works with math.round. but I dont want to randomize the flashes I want it to be in sequence order ( 1,2,3) not 3.1,2 or 2,1,3 I hope this was explained good. I hope someone can help me out. I feel like I have 95% done but cant figure out what I am doing wrong to load these in sequence

 

 

----AS3 CODE---------

 

stop();

var movieArray:Array = ['clip0','clip1','clip2'];

 

 

var loader:Loader = new Loader();

var index:int = movieArray.length * Math.random();

var url:String = movieArray[index] + '.swf';

trace("Attempting to load", url);

loader.load(new URLRequest(url));

loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, loaderComplete);

loader.contentLoaderInfo.addEventListener(IOErrorE vent.IO_ERROR, loaderIOError);

addChild(loader);

 

 

function loaderComplete(e:Event):void {

trace("Successfully loaded", url);

}

function loaderIOError(e:IOErrorEvent):void {

trace("Failed to load", url);

}

Link to comment
Share on other sites

Hi and Welcome to the forums.

 

Maintaining and accessing persistent data between swf sessions isn't something that really falls within the realm of GreenSock products.

 

Take a look at this tutorial on Flash's shared object, which is sort of like Flash's version of a browser cookie: http://www.emanueleferonato.com/2008/12/28/understanding-as3-shared-objects/

 

You will see that each time that page reloads, a new number is displayed. You can very easily use that number to fetch a url out of your movieArray. Give it a shot. Let us know if you have any problems with your SWFLoader.

 

Happy Loading!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×