This is a revise to the flash actionscript tutorial on converting negitive numbers to positive numbers.
Now use Abs() function in flash actionscript
Math.abs()
The flash Math.abs() method is used to return the absolute value of x. This basically means it returns the distance between 0 and x in flash actionscript.
Although -5 is a negative number, it's absolute value is the same as 5. This is because -5 has a distance of 5 from x just as 5 has a distance of 5 from x.
Example:
Math.abs(-10); // Returns 10
Math.abs(10); // Returns 10
Old Tutorial on Converting Negatives to Positive and Positive to Negative numbers
I needed to know the simples way to convert a number from
positive to negative or negative to positive in actionscripts.
Here it is:
[actionscripts]
// convert 100 to negative -100
n = 100;
n = - n;
trace(n);// will = -100
// convert -55 to positive 50
n = -50;
n = - n;
trace(n);// will = 50
[/actionscripts]
This is how it work. Zero minus a positive number = a negative
number. And Zero minus a negative number = a positive number.
NewSourceMedia is providing links to these listings as
a courtesy, and makes no representations regarding the content or
any information related thereto. Any questions, complaints or claims
regarding the downloaded content or details must be directed to the appropriate
publisher. We do not encourage or condone the use of any
software in violation of applicable laws.