Skip to main content
Inspiring
November 30, 2007
Question

getting info on objects loaded via xml

  • November 30, 2007
  • 5 replies
  • 837 views
Hello:

i am a beginner/intermediate as3 coder, and i am stuck on something related to objects loaded via XML.

i am able to load JPEG images onto a simulated "shelf", but i am trying to arrange them on the shelf (like a store shelf) so that each new item is placed directly next to the previous item as they load. i can get it to work on a very basic level by specifying the spacing between items manually betwen the code, but to makre this reuseable and efficient, the ideal is to have the "next" object loaded be placed on the shelf based on the width of the previous object. but when i try to access the width of the object that is loaded via the imageLoader, i can;t find it. if i trace the image loader wifth, it is 0; i have tried several ways to name the object as it loads and then get/save its dimensions somehow, but i am not having any luck. i use all the Lynda titles and i also use some of the better books, but i just can;t seem to solve this.

any hellp would be appreciated.

thank you.
This topic has been closed for replies.

5 replies

kglad
Community Expert
Community Expert
December 2, 2007
you're welcome.
bobba1Author
Inspiring
December 2, 2007
kglad -- thank you so much! this did it!

this was a great help to me after months of trying to get it to work.

i appreciate your time.

best,

bob
kglad
Community Expert
Community Expert
December 1, 2007
show the code you're using to load your images using the attach code option
bobba1Author
Inspiring
December 1, 2007
here is the code; i am new to coding so i am not very good at keeping it neat or explaining it so well.

if, howver, you can follow this, i would appreciate any help. have been trying to crack this basic concept for months using lynda.com, books, et all but not having much luck.

i appreciate you time.

best

bob
kglad
Community Expert
Community Expert
December 2, 2007
try:

kglad
Community Expert
Community Expert
December 1, 2007
assign each item's position when it completes loading.
bobba1Author
Inspiring
December 1, 2007
Thank you -- the problem i have is i don't know how to assign numbers 2,3,4 etc in the middle of loading, because i can;t figure a way to let the next graphic know where it should go to. in other words, in order to ba able to assign it a position, i need to be able to tell it the width of the prviously loaded item, which i can't figure out how to do. i am stuck on this.

thanks
kglad
Community Expert
Community Expert
November 30, 2007
you must wait until loading is complete before you can access the width of a loaded image: use your loader's contentLoaderInfo properties COMPLETE event listener.
bobba1Author
Inspiring
December 1, 2007
Thak you for this -- it did help somewhat, but i am still stuck.

When i use the contentLoaderInfo listener, you are right, i can discern the width of the loader. but when i do this it only works for the last item loaded. here is my problem -- i am trying to load graphics dynamically, and have each graphic go to it's proper "place" on a simulated shelf -- so the foirst object might go to (0,0), then next object should go directly to the right of the first object, etc, etc. and i am loading all this dynamically from an xml file. if i just specify a distance, then i can get everything to load at uniform distances from each other. problem is each of the graphics has a unique width, height, etc, so i need to be able to "catch and capture" this info as each one is loaded. when i wait until the entire loader has loaded, the only peopoerties left for me to capture and use are the propoerties of the last itm loaded.

any ideas on how to do this -- anyone?


thanks very much, i just can't seem to figure this out.