Okay i looked through the actionscript dictionary and found that math.round(mynumber) rounds down. But how do you use it correctly for example: Point = math.round(nAdvertisingPoint) /10; trace(Point); But it gives me a strange error saying : NaN How do i fix this? im new to actionscript =/ im not exactly sure what to do. I followed the example in the actionscript dictonary pretty well.
The the error is likely to be in your variable 'nAdvertisingPoint' If this holds text (or something other than a number), then you will receive NaN which represents Not a Number. if you check that variable to ensure it is reporting as a number you shouldn't have any other troubles... I tested the rest of that small code with : nAdvertisingPoint = "347.9876" Point = Math.round(nAdvertisingPoint) /10; trace(Point); and the output is : 34.8 I hope that helps. cheers,
that shouldn't matter... the code doesn't care where the variable comes from... only that it requires it to be a number... try this in your code: trace("nAdvertisingPoint contains " + nAdvertisingPoint + " and is a type of " + typeof(nAdvertisingPoint)); Point = Math.round(nAdvertisingPoint) /10; trace(Point); if you don't get back something like : output : nAdvertisingPoint contains 348.7653 and is a type of number then you are going to get NaN as your Point. as I said, check what your incoming value is for nAdvertisingPoint ... the rest of the code is correct.
Don't see what you're looking for? Try a search.
|