Jump to content
Search Community

Append a LoaderMax object?

firststephen test
Moderator Tag

Recommended Posts

Hi. I'm loading arrays of assets that may be a number of different types. I read in the documentation that you can append a LoaderMax. My interpretation of this is in this simplified code:

var queue:LoaderMax;
var loadermax_media:LoaderMax;

//thumbsArray is an array of thumbnail jpgs.
//mediaArray is an array of various types (jpgs, movies)

LoaderMax.activate([ImageLoader, SWFLoader, VideoLoader]);


queue = LoaderMax.parse(thumbsArray,
										{
										name: "thumbnails",
										maxConnections:1,
										onProgress:_progressHandler,
										onComplete:_queueCompleteHandler,
										onChildComplete:_childCompleteHandler}
										) ;

//The documentation says that 'parse'returns a LoaderMax object, so ...
loadermax_media = LoaderMax.parse(mediaArray,
										{
										name: "ob1_media",
										maxConnections:1,
										}
										) ;

queue.append(loadermax_media);
queue.load();

		private function _queueCompleteHandler(e:LoaderEvent):void
		{
thumbsArray = LoaderMax.getContent("thumbnails");//thumbsarray is ovewritten by loaded images
mediaArray = LoaderMax.getContent("media");//mediaArray is overwritten by loaded assets
}

I'm getting content DisplayObjects in the final arrays, but too many in the thumbArray when I use 'append'. When I don't use 'append', it works fine. So is this the wrong approach?

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

I'm not 100% clear what you are asking.

 

If you append the mediaArray loaders to the queue (which contains the thumbsArray loaders and has the name:"thumbnails") then when you call getContent("thumbnails") it will give you the content for thumbsArray and mediaArray. That's what I'm assuming is happening but its hard to look at code and guess. In other words it looks like you are placing the the mediaArray loaders inside the LoaderMax that was originally created when you parsed thumbsArray.

 

You may want to make a main LoaderMax and add both child LoaderMax's to it.

 

You could also do some tests using LoaderMax properties like numChildren to see how many loaders are in a LoaderMax or perhaps the getChildren() method to see exactly what the children of a particular LoaderMax are.

Link to comment
Share on other sites

Hi Carl, thanks for your reply.

 

If you append the mediaArray loaders to the queue (which contains the thumbsArray loaders and has the name:"thumbnails") then when you call getContent("thumbnails") it will give you the content for thumbsArray and mediaArray.

I think that's what's happening. I'm getting more loaders from the 'getContent' call than I expect.

 

All I'm trying to do is to load assets from different arrays (ie, from xml) using LoaderMax's ability to parse arrays (and to have a preloader 'see' all the assets). I'm using 'getContent' to create references to the assets so I can add them to the stage in another class (so I need 'getContents' to return just the loaders in one array. For example, 'thumbsArray = LoaderMax.getContent("thumbnails");' needs to be a reference to just an array of loaders for the thumbnails.)

 

Clearly I'm not quite understanding how LoaderMax is supposed to work. I'll try making the main LoaderMax and adding the child LoaderMax's (created with 'parse') to it.

 

If what I've said here makes it clearer, please don't hesitate to make other suggestions.

 

Thanks again,

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...