-
simple math functions causing undefined errors
This seems rather simple but I couldn't find anything on this in a search.
I am using the math functions such as math.round and math.abs.
This works fine if I do a test such as: math.round (2.75). The output is fine.
But when I pass a variable in (this variable has a number value), I get 'undefined' as a result every time. I never had this problem in Flash 4 but Flash MX is killing me!
I'll provide a code snippet. This is breaking my brain, it seems perfectly fine. When I trace my variable, it outputs a number to two decimal places. So it is number format. But if I run the math functions on it... UNDEFINED!
Please help.
The below actionscript uses a changing number value from another movie clip, rounds it to the nearest integer, then goes to a frame with that value in the current movieclip. Simple stuff, but it's not working if I add the math.round function.
onClipEvent (enterFrame) {
var a = _root.bank1_mc.bankvalue;
if (a <= 0) {
a = 1;
}
trace (a);
a = math.round (a);
trace (a);
gotoAndStop(a);
}
This is the output:
0.1
undefined
0.2
undefined
0.3
undefined
0.4
undefined
0.5
undefined
0.6
undefined
0.7
undefined
0.8
undefined
0.9
undefined
1
undefined
1.1
undefined
-
A further diagnostic modification:
var b = 2.9485847;
var c = math.abs(b);
Trace output gives me
b = 2.9485847
c = undefined
WTF?
-
Math.round not math.round
-
Hsalf
Originally Posted by moagrius
Math.round not math.round
Dang you said it before me... oh well...
-
Curse case-sensitive naming! I'm too used to C++. And Flash 4.
Thanks.
-
Hsalf
Originally Posted by tanelorn
Curse case-sensitive naming! I'm too used to C++. And Flash 4.
Thanks.
Yup C++ spoils you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|