Hello, The following test does not work. The nodeType for the data is 3 (text), and the values are returned as a 0 or 1, yet I can't do a simple test on that. Any ideas anyone? I think it is some sort of data type mismatch between xml and strings in Actionscript. if (this.firstChild.childNodes.nodeName == "values") { the_values=this.firstChild.childNodes; if (the_values.childNodes.childNodes.nodeName=="dt_spsd"){ isvalidit= the_values.childNodes.childNodes.nextSibling.nextSibling.firstChild.nodeValue; isvalid = isvalidit; if (testval == "0") { temp_time = "stand by..."; temp_corr = "stand by..."; } else { temp_time = the_values.childNodes.childNodes.firstChild; temp_corr = the_values.childNodes.childNodes.nextSibling.firstChild; } }
Try casting isvalid to a String. if(String(isvalid) == "0"){ //your stuff here.. }else{ //your other stuff.. } Cheers,
Unfortunately, that doesn't work. If I change the comparison to != instead of == I get the message "stand by..." (so the if comparison is taking place - that much is clear), but not when the condition should be satisfied when isvalid is zero. I also tried creating a variable called var mytest:String; and setting mytest = String(isvalid); then doing the comparison mytest == "0" but the results are unchanged.
So when you trace isvalid, what value show up in the output window? Cheers,
Thanks FlashTastic, I appreciate your interest. I moved the discussion over to the Flash Data Integration area as I thought that might be more appropriate. If I do trace isvalid, I get 0 back. If I do typeof(isvalid) I get String back. I set the xml to type string this morning by setting mydataXML.toString(); when loading the xml file, to solve any type issues.
Casting a String to Boolean always returns true. Have you tried casting it to a Number? if(Number(isvalid) == 0){ //etc. } Cheers,
You nailed it! Num won't cast it, but parseInt will: if(parseInt(isvalid) == 0)
Beer over the internet... mmm... *drool*. I'm still at work, it's not nice to make a man salivate on Friday afternoon. Glad you got it all figured out. Cheers, FlashTastic
Don't see what you're looking for? Try a search.
|