Something really wierd!?!?

hey everyone - i have an interesting one for you.

i’m loading data from mysql, through php to flash. very simple data. each row in the table contains 4 fields. one of them has a name of an image to be loaded into flash.

i manage to load the data normally. i receive it in flash as a long string with different symbols separating them. i think split the string into an associative array. when i call the data, it reads it (and it traces properly) but it’s as if the file isn’t found! i’m trying to load pngs, but i also tried with jpgs and it still doesn’t work!

here is the code when loading the image:


for (i=0;i<totalToLoad;i++) {
...load("images/" + mainMenu.groupVars.tG + "/" + theGroup*[0] + ".png", tempGroupItems*.hh)
}

the funny thing is, is when i use the following code it works:


for (i=0;i<totalToLoad;i++) {
...load("images/" + mainMenu.groupVars.tG + "/" + (i+1) + ".png", tempGroupItems*.hh)
}

** the difference is that instead of using the name from the array, i’m just calling files named with numbers (ie 1.png, 2.png, etc.). i also tried hard coding the file name to the name of the file (ie “thefilename”) instead of the array and it also works! its’ got to be something with the array.

any idea what is going on!? the funny thing is, is that i’ve done this SO many times and it’s worked!

thanks!

the values inside the array - and they are all strings…
… look, i’m sure that the array has been built correctly and holds the information that i need. remember, that i also trace the path of the image and it traces correctly. for some reason, that path isn’t loading the image…

i’ve done that for hours and i can’t believe my eyes when i see the the path is being shown correctly! i’m sure that the correct path is shown exactly as you suggested…
i’m going to try to take just the relevant MCs and code and place them in a new file and see what happens…
like is said before, if i just switch the array value with a regular string(ie “one”), it loads that image over and over again… so the load function is working, it’s finding the file, but when i replace it with the array value (which also traces correctly with a tring inside), it doesn’t work.

you see, i’m telling you this is weird!

well, i tried to move them to a new file… no code hidden in other mcs…
still i get the same thing…
the loader is working if i hardcode a file name, but not if i use a value inside the array that i collected using loadvars (from mysql)

It’s possible that the code is operating before Flash has managed to load the SQL data. You say that you’re sure the array has been built correctly etc., but I’m inclined to think that it’s returning undefined values.

i don’t mean to brag at all, but i’ve been actionscripting for a few years now and i know quite a bit about these things. i’m sure that the data has been loaded correctly.

one line before i ask to load 10 files (which in some of them, i ask for the same image), i trace this:
“images/” + groupVars.tG + “/” + theGroup*[0] + “.png”;

and i get this:
1: images/necklaces/abc.png
2: images/necklaces/def.png
3: images/necklaces/ghi.png
4: images/necklaces/abc.png
5: images/necklaces/def.png
6: images/necklaces/ghi.png
7: images/necklaces/ghi.png
8: images/necklaces/ghi.png
9: images/necklaces/ghi.png
10: images/necklaces/abc.png

(ignore the 1: 2: etc - that’s just from my tracer that i wrote for use in the browser)

but according to my loaded object, it just isn’t downloading the file. when i change the array value to say “abc.png” instead of theGroup*[0], it loads that image 10 times. so the loader is finding the files – just when its coming from the array, it doesn’t…

i’m using the ondata function to receive the data through a loadvars.sendAndLoad call to the php script… maybe that’s the reason??? i don’t really think so because i’m using a very similar function elsewhere and it does work.

I’m not knocking your scripting abilities…just looking to narrow the problem down by eliminating some likely causes. And, from what you say now, it’s definitely a problem with the array (theGroup) and that seems to point towards scoping; possibly because it resides locally within another function which your loaded object can’t access.

Ooops, didn’t see the above post but zenaphex’s solution does seem to confirm that scoping is the problem.