Skip to main content
Known Participant
January 4, 2011
Answered

Problem with If Statement

  • January 4, 2011
  • 1 reply
  • 946 views

Well, my first post here, hope i can solve this 😃

The problem is that i do have a if that seems to not obey me:

if (_parent.foto2 == 'no' ) {

btNext._visible = false;

}

I believe I am having some problem with the variable "foto2". I  tried tracing, and if I add a 'trace ('_parent.foto2') right before the if, the result is 'no'.

So i'm 100% that what's inside the var on the moment of the loop is 'no'. I can even use it to change dynamic text boxes to 'no'.

What maybe possible is that it's a type of var that if  doesn't understand maybe?

So i'll try to be short explaining from it comes.

I'm doing a gallery where a click on a thumbnail leads to a zoom image, or images, based on XML, so firstly I prepared a set of vars from the xml:

function checkLoading(success) {

if (success == true) {

var totalNodes = imagesXML.firstChild.childNodes.length;

for (i=0; i< totalNodes; i++){

fotoEnd = 'images/lookbook/' + imagesXML.firstChild.childNodes.firstChild.firstChild;

this["fotoToLoad"+i] = fotoEnd;

this["fototwo"+i] = imagesXML.firstChild.childNodes.childNodes[1].firstChild;

this["text"+i] = imagesXML.firstChild.childNodes.childNodes[2].firstChild;

}

frame1.loadFirst (this);

}

}

The last function there, loadFirst, runs inside the thumbnail, it it uses fotoToLoad+i as the thumb to load (and also the first zoom image), fototwo+i as the second image of zoom (wich might be an image filename or a 'no', wich i would use as control to showor not the brNext button). And the text+i is the images's description. I'm also forwarding the this to the function so that i can use the vars there.

On the thumbnail mc I have a moviecliploader working, so that it will fun the followin after load ends:

foto25 = varHold.fototwo1;
Varhold is the forwarded this. I'm setting it the values to a var there because I want to leave it avaible inside the thumbnail, for when the user clicks it a function will load the first image and, onLoadInit, forward those vallues to a variable in _root, this way I can do one zoom mc that checks always the same vars on root.
So when the thumb is finally clicked, there's a moviecliploader to load the first big image, and onLoadInit it runs this:
_parent._parent.foto2 = foto25 ;
_parent._parent.texto = texto;
Creating finally the var i use in the if that is giving me the trouble.
I just don't know what i did not do, but the var is just un-usable for the if statement, even thou I can use it's values to load images, output text, do traces and such. =(
Thanks in advance to whom read this, for I'm already gettin a bit nuts since i've been checking this over and over for the last 4/5 hours -.-.

This topic has been closed for replies.
Correct answer kglad

so, that means _root.foto2 is NOT a string (if your spelled length correctly in your code).  did you and if so, what data type is it?

1 reply

kglad
Community Expert
Community Expert
January 4, 2011

check for whitespace:

trace(_parent.foto2+" "+_parent.foto2.length);

if (_parent.foto2 == 'no' ) {

btNext._visible = false;

}


Participant
January 4, 2011

Thank you, I guess the result was rather "intersting".... the lenght resulted in "undefined":

results:

no undefined

=(

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 4, 2011

so, that means _root.foto2 is NOT a string (if your spelled length correctly in your code).  did you and if so, what data type is it?