Jump to content
GreenSock

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

Problem loading LoaderMax XML node on demand

Recommended Posts

I have an XMLLoader which loads an XML containing 2 LoaderMax objects, one with load="true" and one with load="false".

 

When the XMLLoader triggers onComplete, I start my app and want to request the second LoaderMax to start. When I do this, however, the assets never seem to start loading.

 

Am I calling things correctly?

 

// XML
<GameAssets>

<LoaderMax name="Subload" load="false" childrenVars="autoPlay:false">
	<VideoLoader url="videos/Main/M1.f4v" name="M1MainAnimation" autoDispose="false" />
</LoaderMax>
</GameAssets>

 

// AS3
private function _onLoadComplete(e:LoaderEvent):void
{
  trace("ASSETS LOADED");

  var subLoader:LoaderMax = LoaderMax.getLoader("Subload");
  subLoader.vars = { onProgress:onSubloadProgress }
  subLoader.load();
}
private function onSubloadProgress(e:LoaderEvent):void
{
  trace("THIS NEVER HAPPENS?");
}

Link to post
Share on other sites

The problem is this line:

subLoader.vars = { onProgress:onSubloadProgress }

 

The vars object is really only parsed in the constructor - you can't just add/replace properties after the instance is created (well, you can but they'll be ignored). The solution is to simply use the addEventListener() method to add your listener(s), like:

 

subLoader.addEventListener(LoaderEvent.PROGRESS, onSubloadProgress);

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.

×