Jump to content
Search Community

Preloading multiple swf and calling them?

vrex test
Moderator Tag

Recommended Posts

Hey guys i'm making a small story game and using toonboom to do the animation (which i export out as swfs).
 
Ingame on stage i want to call a specific swf (or random depending on the place).

I have looked around the site but i'm having problems preloading all the swf and loading a specific one.
Example:

 
var queue:LoaderMax = new LoaderMax({name:"mainQueue"});
 
queue.append( new SWFLoader("anim1.swf", {name:"idle1", estimatedBytes:40000, container:this}) );
queue.append( new SWFLoader("anim2.swf", {name:"idle2", estimatedBytes:40000, container:this}) );
queue.append( new SWFLoader("anim2.swf", {name:"idle3", estimatedBytes:40000, container:this}) );
queue.load();

 
This works and puts it on stage, but it always only puts the last thing in the list (which is idle3) on top. I can't figure out how to make it put only idle2 or only idle1 instead. If i put properties like x:-200 for idle1, it wlill show up to the left, but how would I hide idle2/idle3 from appearing?
 
Before trying loader max i used the traditional swfloader in as3, and while this works the problem is that every time it loads an animation the whole character animation "blinks" (i'm loading this locally from my hdd) and makes it look jumpy since every transition is a blink.

import flash.utils.Timer;
import flash.events.Event;

var idleloader= new Loader(); 
var swf_idle_store:Array = ["anim1.swf","anim2.swf","anim3.swf"];
var idleTimer:Timer =new Timer(3000,0);

idleTimer.addEventListener(TimerEvent.TIMER, random_idle_swf);
idleTimer.start();


function random_idle_swf(e:Event):void {
var tempnumb:int;
tempnumb=Math.random()*swf_idle_store.length;
rariloader.load(new URLRequest(swf_idle_store[tempnumb]));	
addChild(idleloader);	
}


I figure the way around this would be to preload all the animations, and loadermax seems to do that if i could just figure out how to make it load a specific thing after preloading. 

Link to comment
Share on other sites

one thing you can do is set alpha to 0 of all the SWFLoaders like

 

queue.append( new SWFLoader("anim1.swf", {name:"idle1", estimatedBytes:40000, container:this, alpha:0}) );
queue.append( new SWFLoader("anim2.swf", {name:"idle2", estimatedBytes:40000, container:this, alpha:0}) );
queue.append( new SWFLoader("anim2.swf", {name:"idle3", estimatedBytes:40000, container:this, alpha:0}) );
 
Now all of them are invisible.
 
To show the third one you could do
 
LoaderMax.getLoader("idle3").content.alpha = 1
 
Here is a tutorial that explains some of the basic features of LoaderMax

 

http://www.snorkl.tv/2011/08/loading-images-with-loadermax-load-and-track-the-progress-of-multiple-images/

 

 

Just so you know we have been sunsetting our AS3 loading tools for quite awhile so support is very limited.

  • Like 1
Link to comment
Share on other sites

one thing you can do is set alpha to 0 of all the SWFLoaders like

 

queue.append( new SWFLoader("anim1.swf", {name:"idle1", estimatedBytes:40000, container:this, alpha:0}) );
queue.append( new SWFLoader("anim2.swf", {name:"idle2", estimatedBytes:40000, container:this, alpha:0}) );
queue.append( new SWFLoader("anim2.swf", {name:"idle3", estimatedBytes:40000, container:this, alpha:0}) );
 
Now all of them are invisible.
 
To show the third one you could do
 
LoaderMax.getLoader("idle3").content.alpha = 1
 
Here is a tutorial that explains some of the basic features of LoaderMax

 

http://www.snorkl.tv/2011/08/loading-images-with-loadermax-load-and-track-the-progress-of-multiple-images/

 

 

Just so you know we have been sunsetting our AS3 loading tools for quite awhile so support is very limited.

Thank you, that's just what I needed! I was trying to access the content but was having no luck looking through the posted examples. That did the trink (i just used visible instead of alpha so it's not rendering).

  • Like 2
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.
×
×
  • Create New...