USERNAME:
PASSWORD:
Save Info!
Logging in…
This topic is 1 page long.
[ Profile | Posts | Contact ]
Posted at: 3/18/09 12:52 PM
Sign-Up: 01/17/09
Posts: 1,334
can anyone help me with why this returns NaN when it shouldn't?
on(release){ time = 100; idiot = ""; if(fashScoreDev == Infinity){ flashScoreDev = 0; } if(making == true){ flashDays += 1; if(flashDays == daystowork){ flashScoreFinal = flashScoreDev*(.5+Math.random()); flashScoreDev = 0; trace(flashScoreFinal); }else{ flashScoreDev = (_root.flashSkill/10 + _root.soundSkill/12.5 + _root.artSkill/10 + _root.cSkill/10 + daystomake/10)/6; trace(flashScoreDev); } } }
Got The World's Best Band Name?
Posted at: 3/18/09 12:59 PM
Sign-Up: 12/19/05
Posts: 2,332
fashScoreDev
Posted at: 3/18/09 01:01 PM
... yes i know that flashScoreDev is what returns NaN, but it should be a value. i don't know why it isn't. sorry if i wasn't clear.
Posted at: 3/18/09 01:04 PM
fashScoreDev. Misspelled.
if(fashScoreDev == Infinity){
You'd end up multiplying with a null, which should become NaN.
Sign-Up: 06/13/07
Posts: 1,013
not sure if this'll help you, but NaN stands for Not a Number.
This is put into a variable when you put an illegal content into a variable. For example this would return NaN:
var var1: Number; var2 = "this is a string";
var1 += var2;
obviously, you can't add a string and a number, and var1 would now contain NaN.
hope this helped. too lazy to check ur code, sorry.
Awesome turret game in the making, featuring 85 uniqe turrets: News post
Posted at: 3/18/09 01:09 PM
At 3/18/09 12:59 PM, WolfAkela wrote: fashScoreDev
ah, thank you, now i understand. thanks for the help.
Posted at: 3/18/09 01:12 PM
damn, no sorry it still returns NaN. i can't find out why. it's in this part i know
}else{ flashScoreDev = (flashSkill/10 + soundSkill/12.5 + artSkill/10 + cSkill/10 + daystomake/10)/6; trace(flashScoreDev);
because flashDays isn't equal to daystowork....
Posted at: 3/18/09 01:18 PM
Sign-Up: 11/12/03
Posts: 524
the first time you posted that you had _root. attached now its gone... maybe that?
Posted at: 3/18/09 01:23 PM
Sign-Up: 03/09/03
Posts: 2,595
Make sure all your variables are cast as Numbers.
Posted at: 3/18/09 01:28 PM
At 3/18/09 01:18 PM, ColdLogic wrote: the first time you posted that you had _root. attached now its gone... maybe that?
i tried it w/ and w/o the _root. and both didn't work.
At 3/18/09 01:23 PM, Cojones893 wrote:
:Make sure all your variables are cast as Numbers.
yup, here are my vars, posted one frame before:
stop(); Mouse.show(); var flashSkill:Number = 0; var artSkill:Number = 0; var soundSkill:Number = 0; var cSkill:Number = 0; var time:Number = 100; var idiot:String = ""; var flashname:String = ""; var daystowork:Number = 0; var making:Boolean = false; var flashScoreDev:Number = 0; var flashScoreFinal:Number = 0; var flashDays:Number = 0;
Posted at: 3/18/09 01:53 PM
are they all declared on the main timeline?
Posted at: 3/18/09 01:56 PM
Sign-Up: 03/06/09
Posts: 645
try tracing all the variables in that statement, maybe it's one of those
Getting bored? View my art, Read a story or visit the Programming Forum Projects page
yup. their all on frame two, while the button in question is a part of frame 3.
Posted at: 3/18/09 01:59 PM
well im not sure about that other frames thing, but if you declare your vars on the main timeline, im pretty sure you cant access them without haveing _root. in front of them, since there scope is the main timeline and your trying to just access them inside a button.
i would change every reference to a variable in that code to include _root. in front of it, i could be mixed up here but I think that should work.
Posted at: 3/18/09 02:00 PM
At 3/18/09 01:56 PM, kiwi-kiwi wrote: try tracing all the variables in that statement, maybe it's one of those
yup, i think that's it. it came out with
NaN 1 1 1 0.5 undefined
so it's got to be daystomake... ok, i got it now. thanks a load everyone.
All times are Eastern Standard Time (GMT -5) | Current Time: 11:26 PM
<< Back