Can somebody Explain This Actionscript Line of Code to me?
var loc3:*=Math.min(Math.max(arg2 / arg1.things开发者_Python百科, 0), 1);
If somebody could breakdown what this line of code is doing, i'd greatly appreciate it.
You could rewrite it in the following sequence of steps:
VALUE1 = arg2 / arg1.things // STEP 1 divide arg2 by arg1.things
VALUE2 = Math.max(VALUE1, 0) // STEP 2 if the value of the division at step 1
is less then 0, set the value to 0
VALUE3 = Math.min(VALUE2, 1) // STEP 3 if the value is greater than 1
set the value to 1
VALUE4 = loc3 * VALUE3 // STEP 4 multiply the value by the current value
stored in loc3
var loc3 = VALUE4; // STEP 5 and set the final value back to loc3
So, to summarize, what that line of code does is it divides the value of arg2
by the values stored in arg1.things
and it caps the result in the closed interval [0,1]
and then it multiplies the value stored in loc3
by the capped, computed result of the division. The final result is stored back in the loc3
variable.
精彩评论