Jump to content
Search Community

Converting Queue Object to Array Object?

soupking test
Moderator Tag

Recommended Posts

Hi Everybody,

 

I've been busy getting the hang of LoaderMax the past day or two. I've noticed there's a number of ways to approach LoaderMax. Overall, I've decided to take the batch queue approach even though I'm only loading one type of asset. That way I can us the same methodology evenly for most applications.

 

What I can't seem to wrap my head around is how to convert a queue imageloader object into an array reference.

 

Here's the code I have so far:

 

//create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners
var queue:LoaderMax = new LoaderMax({
					name:"imgQueue", 
					onProgress:iProgressHandler, 
					onComplete:iCompleteHandler, 
					onError:iErrorHandler
					});

for (var i:Number = 0; i {
//append one or more loaders
queue.append( new ImageLoader("_images/"+xml.feature[i].@url, {
									  estimatedBytes:2400, 
									  container:container_mc, 
									  alpha:1,
									  y:10+30*i
									  }) 
					 );
}		

queue.load();

 

So I have this queue.append...ImageLoader. How do I properly assign something like that to _imageArray within the same for loop?

 

I can figure out how to transfer all the XML data, but putting a content display object in between this loop process is kind of confusing in terms of type and reference. What do people do to make that conversion?

 

Thanks for reading> :)

Link to comment
Share on other sites

not sure what you are asking but if you want an array of the loaded images, LoaderMax.content gives you that. So in your code, just add _imageArray=queue.content; after the for loop.

 

if you want to do it manually inside the for loop I guess it would be

var l:ImageLoader;
for (var i:Number = 0; i {
//append one or more loaders
l=new ImageLoader("_images/"+xml.feature[i].@url, {
                               estimatedBytes:2400, 
                               container:container_mc, 
                               alpha:1,
                               y:10+30*i
                               })
_imageArray.push(l.content);
queue.append(l);
} 

Link to comment
Share on other sites

Ahh okay. That makes sense.

 

So per your response, "l.content" is the imagein in the image loader instance?

 

Cool, so when I reference _imageArray.push(l.content), the array is storing the loaded object.

 

What about all the properties of the object (e.g. estimated bytes etc.)? Are they just assigned but not instanced or something?

 

not sure what you are asking but if you want an array of the loaded images, LoaderMax.content gives you that. So in your code, just add _imageArray=queue.content; after the for loop.

 

if you want to do it manually inside the for loop I guess it would be

var l:ImageLoader;
for (var i:Number = 0; i {
//append one or more loaders
l=new ImageLoader("_images/"+xml.feature[i].@url, {
                               estimatedBytes:2400, 
                               container:container_mc, 
                               alpha:1,
                               y:10+30*i
                               })
_imageArray.push(l.content);
queue.append(l);
} 

Link to comment
Share on other sites

l.content is a ContentDisplay object that extends Sprite - meaning it's a sprite with some extra properties and methods. It is what greensock loaders use as a container it loads. You can use it and manipulate it just like a regular display object on screen (x, y, scaleX, scaleY, rotation, alpha, width, height, etc etc).

 

Also you can pretty much forget about the loaders and LoaderMax once they've done their job loading your images. See it this way, loaders are just responsible for loading and LoaderMax is just a queue of loaders. They are useful to use to organize and get information for the loading process. You can learn more about each class at http://www.greensock.com/as/docs/tween/ under the com.greensock.loading packages.

 

hope this helps somewhat... also didn't see a need for that new thread~

Link to comment
Share on other sites

l.content is a ContentDisplay object that extends Sprite - meaning it's a sprite with some extra properties and methods. It is what greensock loaders use as a container it loads. You can use it and manipulate it just like a regular display object on screen (x, y, scaleX, scaleY, rotation, alpha, width, height, etc etc).

 

Also you can pretty much forget about the loaders and LoaderMax once they've done their job loading your images. See it this way, loaders are just responsible for loading and LoaderMax is just a queue of loaders. They are useful to use to organize and get information for the loading process. You can learn more about each class at http://www.greensock.com/as/docs/tween/ under the com.greensock.loading packages.

 

hope this helps somewhat... also didn't see a need for that new thread~

 

Yeah, I suppose it was overkill. Lame on my part. I'm just trying to get these queued objects (whatever they are) into a referencable, depthable medium, you know? Like, for reference with all XML data I've been using arrays, so I did the same thing for images, but in my mind it looks like this:

 

container = img1, img2, img3, img4

 

But it's not an array, so...I've got 4 ContentDisplay objects in a MovieClip? Am I warm? Heh, sorry if I sound daft. I am just lousy at AS3, have been ever since it came out. I spent 6 months of focus to get it, learned it, everybody made me work in AS2 all year, I lost it, now I'm trying to learn LoaderMax.

 

Sorry for any hassle, I've just been going in circles from one thing to another. That's why my double post was an accident.

 

Bottom line, I'm trying to reference/map this loaded content so I can swapdepths the loaded images. That's another thing I'm adapting as well as duplicateMovieClip and recursive button events...(Sigh) but that's for another forum if needed. :)

 

Thanks for reading/responding holysocks. :)

Link to comment
Share on other sites

I understand the basics of the display object model.

 

container_mc.addChild(LoadedObject_12);

 

It's essentially the same thing

 

I don't understand LoaderMax because I can't treat the objects loaded like MovieClips in that they are at a depth:

 

http://www.greensock.com/as/docs/tween/ ... etail.html

 

I can tween them, but I can't re-stack them.

 

My major issue right now is referencing what is in the container as a separate depth. I imagine that I can GetByName, but every swapDepths, getDepth() function I've thrown at it is rejected.

 

I want to be able to do this:

http://www.as3dtk.com/?p=493

 

See my issue? I've seen slideshows that go back and next down the aggregated XML data or array. But I have a 4 button menu.

 

Should I somehow in the loop store each ContentDisplay object into it's own MovieClip instead of just a container_mc. Is that the logic?

 

Thanks for your response by the way. :)

Link to comment
Share on other sites

this will swap image at i with the image that's at the top of the displaylist of container_mc (pushes it above all other images)

container_mc.swapChildren(_imageArray[i],container_mc.getChildAt(container_mc.numChildren-1));
OR
container_mc.setChildIndex(_imageArray[i],container_mc.numChildren-1);

_imageArray is an array of all the loaded images in container_mc as shown in my previous posts

Link to comment
Share on other sites

this will swap image at i with the image that's at the top of the displaylist of container_mc (pushes it above all other images)

container_mc.swapChildren(_imageArray[i],container_mc.getChildAt(container_mc.numChildren-1));
OR
container_mc.setChildIndex(_imageArray[i],container_mc.numChildren-1);

_imageArray is an array of all the loaded images in container_mc as shown in my previous posts

 

Awesome. The first one works. Saved!!! Thank you!!!

 

I already tried the 2nd you propose, but I've had an array of errors. Probably starting out because I didn't put in the parent container_mc.

 

However, I never would have figured that out that the container_mc was the parent. I was threading with a gentlemen named Carl, and he said to swapDepths that I should container_mc.addChild(_imageArray). However, that then seemd odd to me because it's like I'm instance the loaded content twice. ?

 

Anyway, this will keep me moving forward. Thanks a bunch for the help. This code snippet is much cleaner than where I was headed.

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