Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
jtvalles

parse() and update container

Recommended Posts

I have created an application that passes a url that may be a swf, image or flv.
 
The content will be loaded into the same container. I'm able to load the respective formats, but it creates a new Loader each time. Is there a way to create one Loader for each format and update the container with its respective formats while removing the previously loaded content?
 
For example: I load a jpg into "mc_container" then remove that jpg and load a swf into "mc_container"
 
What I tried doesn't work:
 

public function DisplayVisual() {
LoaderMax.activate([ImageLoader, SWFLoader, VideoLoader]);
}


function loadVisual(visualUrl:String):void {
var visualLoader:LoaderCore = LoaderMax.parse(visualUrl, {name:"parsedLoader", container:mc_container});
visualLoader.load();
}
Link to post
Share on other sites

The short answer is no, you can not create 1 loader that loads multiple asset types.

You can create a loader for each asset type and they all can share the same container.

 

If you create 1 ImageLoader to load all images, and 1 SWFLoader to load all swfs, you will then have to parse the file extensions yourself and then pass the url into the appropriate loader.

 

I would think its fine to dispose and unload visualLoader each time a new asset is loaded. There shouldn't be a ton of overhead involved in that. Something like this:

var visualLoader:LoaderCore

function loadVisual(visualUrl:String):void {
//if the visualLoader exists, dispose and flush content
if(visualLoader){

  visualLoader.dispose(true);
}
 visualLoader = LoaderMax.parse(visualUrl, {name:"parsedLoader", container:mc_container});
visualLoader.load();
}
Link to post
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.

×