View Full Version : [MX] When 1 != 1
lrhb
October 15th, 2003, 06:51 PM
I really think that either I am going crazy, or Flash is trying to kill me.
I've attached a zip containing a fla, the wddx include I use for it, and a sample WDDX file.
As you can tell from the actionscript, it looks for the value of HASVALETPARKING, traces it, confirming it's existence, and should trace the special message in the case of it being equal to 1 (if you think it might help, try "1" as well...)
Can anyone tell me why it's not working?! Please let it be something simple that I am just not seeing...
Thanks in advance!
lrhb :hat:
lostinbeta
October 15th, 2003, 11:33 PM
I believe when you load in your XML file Flash loads the number a String not a Number, so what you will have to do is use a parseInt() to parse it back into a number. So change if (sampleWDDX.HASVALETPARKING == 1) {
trace("WE HAVE NO BANANAS");
} to if (parseInt(sampleWDDX.HASVALETPARKING) == 1) {
trace("WE HAVE NO BANANAS");
} and it works peachy.
Also, I checked out your XML file and I see you ignored whitespace on your own, which makes for quite the unreadable file....hehe. If you wish to space/indent it properly you can, you will just have to be sure to add sampleXML.ignoreWhite = true; to your Actionscript :)
lrhb
October 16th, 2003, 12:19 PM
O' mighty lostinbeta!
I did a few more tests, such as, I did
trace(sampleWDDX.HASVALETPARKING.length);
to see what I'd get, to make sure there was only one character in there... I got "1", so I decided to try it on a different field holding some text about 8 characters long, so something like
trace(sampleWDDX.STATENAME.length);
and I got "1"! So obviously something is up with the parser, or the way it loads XML, or something... so in the end, what I ended up doing was
if (sampleWDDX.HASVALETPARKING.toString() == "1") {
trace("WE HAVE NO BANANAS");
}
and the light shone down upon me from the ActionScript Heavens, and the spirit of Colin Moock spake unto me, "It is good."
So there we have it :beam: Taking a look at the datasource, I noticed everything's coming over as a string, so I'll go ahead and use toString in this instance... but thank you! Now I know my friend parseInt will be waiting for me like a warm glove on the cold, wintery day that I need to use it.
As always, thanks for the help!
lrhb :hat:
lostinbeta
October 16th, 2003, 12:27 PM
Hehe, glad you got everything figured out :thumb:
ahmed
October 16th, 2003, 01:49 PM
Originally posted by lrhb
and the light shone down upon me from the ActionScript Heavens, and the spirit of Colin Moock spake unto me, "It is good."That's funny :beam:
lrhb
October 16th, 2003, 01:54 PM
ActionScripting is a very intense experience for me ;)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.