Jump to content
Search Community

displaying loaded images from an array

icekomo test
Moderator Tag

Recommended Posts

I tried to look on this form for this answer, but didn't have any luck.

I am able to get the xml loaded.

I was able to add those imageLoader nodes into an array, but what I can't figure out is how to then display them.

Here is the code I have:

 

var queue:LoaderMax = LoaderMax.getLoader("dynamicLoaderImages");

//trace(queue.getChildren());

imagesArray = queue.getChildren();

queue.load();

trace(imagesArray[1]+" this is node 1 of array")

trace(imagesArray.length);

 

An addChild(imagesArray[1]); //doesnt work, so i thought I might have to use the contentDisplay property, but not sure how to in conjunction with my array.

 

Thanks!

Link to comment
Share on other sites

try

 

addChild(imagesArray[1].content)

 

 

also you may want to consider using an onChildComplete event listener so every time an asset loads, a function will run that can display and position your assets as needed.

 

 

 

I have a tutorial covering some XMLLoader basics, the approach is a little different than yours as mine is set up to auto load all the loaders in the xml. The way the onChildComplete handler works could be beneficial to you: http://www.snorkl.tv/2011/08/loading-im ... xmlloader/

 

to add CHILD_COMPLETE event to your set up you could do:

 

queue.addEventListener(LoaderEvent.CHILD_COMPLETE, completeHandler)

 

*don't forget to add import com.greensock.events.LoaderEvent up top.

Link to comment
Share on other sites

Carl,

Thank allot for that link... it really cleared up some questions I had about laoderMax. Will you be doing more of them?

I had another quick question, is it possible to put ImageLoder nodes loaded from an xml file into a multiDimensional Array?

I assume it would be, but can I do it by calling the names of the imageLoaders?

 

Say I have an array with 6 image loaders

imageArray = loder.GetChilder();

and then I want to do something like

imageArray[0] = ["image1","image2","image3"];

imageArray[1] = ["image4","image5","image6"];

 

then I want to add a certain image from that array...

 

addChild(imageArray[0][1].content);

 

 

Is doing something like this possible?

Link to comment
Share on other sites

yes you store references to the loaders or their content in an multi-dimensional or any way you seem fit.

 

you can not reference the loaders just by their name strings "image1" "image2" etc.

 

you need to do

 

imageArray[0] =
[
LoaderMax.getLoader("image1"),
LoaderMax.getLoader("image2"),
LoaderMax.getLoader("image3")
]

 

 

but i don't think you want that to be the same array that use for

 

imageArray = Loader.getChildren();

 

 

and yes, I will eventually be getting to more LoaderMax tutorials.

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