PDA

View Full Version : target problem


betamax
01-13-2005, 11:38 AM
Quick question (hopefully) I'm building an xml driven gallery and I've got a bit of a problem targetting images.

This works fine:
jpeg = mySection.childNodes[i].attributes.jpegURL;
trace(jpeg);
But I need to add tnIcon so I can target this from a function using 'this':

tnIcon.jpeg = mySection.childNodes[i].attributes.jpegURL;
trace(tnIcon.jpeg);
This nearly works except the first result is 'undefined' the rest of the results are fine.

Any ideas why this is happening and how to solve it?
Many thanks

Tink
01-13-2005, 12:17 PM
i would presume mySection.childNodes[0] has no value so if you are using a for loop start the count at 1.

when u trace it before, nothing is traced so you are not seeing undefined where as when u try and trace the variable in tnIcon is returning undefined as there is nothing there.

betamax
01-13-2005, 12:33 PM
Hi Tink thanks for your reply, I may have misunderstood you, but i don't think that is the case. The first bit of code outputs this:
pics/01.jpg
pics/02.jpg
pics/03.jpg
pics/04.jpg
pics/05.jpg
pics/06.jpgThe second bit of code outputs this:
undefined
pics/02.jpg
pics/03.jpg
pics/04.jpg
pics/05.jpg
pics/06.jpg

betamax
01-13-2005, 01:55 PM
Hmm I just moved this line of code so that its above the function which uses the valuetnIcon.jpeg = mySection.childNodes[i].attributes.jpegURL;....it works, don't ask me why but it works!! :confused:

Tink
01-13-2005, 07:01 PM
nope u understood me perfectly i was just wrong :(

glash u got it sorted!