Jump to content
GreenSock

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

Feature Request

Recommended Posts

I tried using the LoaderMax.parse for the first time as my data is a mix of images, videos and swf's. However I realized that I would not be able to use it because LoaderMax lacks a getChildAt(index:uint) type method. Let me explain

 

So I have a loadMedia(index:uint) method that gets called whenever media needs to be loaded. It takes in an index. Normally I query the loader I want to load like this:

 

LoaderMax.getLoader("media_" + id);

 

but because I cannot dynamically add an id or a name to each parsed loader I would need to add a name or id attribute to each media node in my XML which is kinda tedious. This kind of situation would be made easier to deal with if there was a getChildAt method for loaders, like this

 


public function loadMedia(index:uint):void{
  var ldr:* = mediaLoader.getChildAt(index);
  ldr.load();


}

Link to comment
Share on other sites

I figured out a work around if anyone is interested.

 


//
//
mediaLoader = LoaderMax.parse(mediaArray,
		   {  // Loader Vars
		  name:"mediaLoader",
		  maxConnections:1,
		  onProgress:mediaProgress,
		  onChildComplete:mediaLoaded,
		  onComplete:allMediaLoaded,
		  onIOError:ioErrorHandler
		   }
);



public function loadMedia(id:uint):void {

 var loaders:Array = mediaLoader.getChildren();
 loaders[id].load(); // Load a single media item
}

 

Unfortunately I still cannot use the .parse method because I need to add estimatedBytes properties to each of my loaders. Which would mean adding LoaderMax nodes to my XML which I don't want to do. I guess this method is really for those adding LoaderMax related nodes to their XML. Very cool feature but just can't use it for what I want to do.

Link to comment
Share on other sites

I'm confused. There already is a getChildAt() method. http://greensock.com...tml#getChildAt() Am I missing something?

 

 

Well how about that...getChildAt doesn't show up in my code hinting for some reason (FlashDevelop) getChildren() and getChildIndex() do but not getChildAt(), should have looked at the docs more closely. I thought it strange you didn't include that feature but you did ;)

 

Now I need a way to switch between which type of loader being returned to my getMedia() method. I could just use a switch statement but I am wondering if LoaderMax doesn't come with a feature I may have overlooked like LoaderMax.type or something?

Link to comment
Share on other sites

I tried searching for that method and believe it doesn't exist in my current LoaderMax Version

 

/**

* VERSION: 1.761

* DATE: 2010-12-07

* AS3

* UPDATES AND DOCS AT: http://www.greensock.com/loadermax/

**/

 

I assume a newer version of LoaderMax has this feature? My version came from a default install of Gaia framework

Link to comment
Share on other sites

I downloaded a newer version of LoaderMax and the getChildAt() method was there, strange that it wasn't a part of my initial install. Was this added in latter versions?

Link to comment
Share on other sites

Yes, getChildAt() wasn't in the original version - it was added later. It has been in there for a while, though.

 

As far as type checking, wouldn't it be as simple as:

 

if (loader is SWFLoader) {
   ...
} else if (loader is ImageLoader) {
   ...
} else if (loader is XMLLoader) {
  ...
}
...

?

Link to comment
Share on other sites

Yes, getChildAt() wasn't in the original version - it was added later. It has been in there for a while, though.

 

As far as type checking, wouldn't it be as simple as:

 

if (loader is SWFLoader) {
...
} else if (loader is ImageLoader) {
...
} else if (loader is XMLLoader) {
  ...
}
...

?

 

 

Yeah that would work great for checking the loaders after they have been created.

 

Thanks Jack

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