-
I have to add the absolute value of two variables but i can'it figure out how. How can i tell flash to add absolute values because i have a problem like this
var1=-125
var2=125
var1-var2=-250
but i need an absolute value
-
If then numbers have decimal places then you use the int function:
set variable:"new variable"= int(1.999999999)
Now to convert a negative number to a positive number you multiply it by -1
set variable:"new variable"= -6 *-1
Hope that helps!
Regards FlashGuru
-
if you dont mind making the original variables both positive then you could say:
if( var1 < 0 ){
set variable: "var1" = var1*-1
}
if( var2 < 0){
set variable: "var2" = var2*-1
}
set variable: abs = var1 + var2
or if you dont want to change the values of var1 and var2 then try :
if( var1 < 0 ){
set variable: "abs" = var1*-1
}
else{
set variable: "abs" = var1
}
if( var2 < 0){
set variable: "abs" = abs + var2*-1
}
else{
set variable: "abs" = abs + var2
}
that should do the trick
hope that is what you are talking about
peace
crax1yt3
-
If flash supports the square root function let's say sqr for example (dont have flash loaded here)
you could cut the code down to:
abs = sqr(val1*val1) + sqr(val2*val2)
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
|