using myVar:Boolean=true as myVar:Int=1

Usually when a bool is true, it has an equivalent binary value of 1.
However in flash I can't do the following:

Code:
var isPowerful:Boolean = false;

Force = (7 * isPowerful + 1) * Thrust;


It gives an error "1067: Implicit coercion of a value of type Boolean to an unrelated type Number"
Can I do explicit type conversion in Flash?

The point was to optimise by avoiding the use of an IF function. I know I could just use an int instead of a bool, but I want to know if this is possible...
Code:
Force = (7 * parseInt(isPowerful) + 1) * Thrust
Force = (7 * (isPowerful ? 1 : 0) + 1) * Thrust


My suggestion though? Just use the if statement 🙂
Thanks mayo. What's that second technique called?
?: = conditional operator
you can aso say

Code:
Force = (7 * int(isPowerful) + 1) * Thrust


thats how i do my movement usually

function keyHandle(e:KeyboardEvent) :void{
switch(e.keyCode){
case 65: l = e.type == "keyDown"; break;
case 68: r = e.type == "keyDown"; break;
//other keys
}
}
function enterFrame(e:Event){
v += (int(r) - int(l)) * s;
}

as you can see I'm hella anal about short names

Edit: did a test, the ?: method is fastest, follow by int() then parseInt()

Original thread: https://box2d.org/forum/viewtopic.php?t=3565