Flash (AS3) Movieclip Rotation

actionscript-3flashmoviecliprotation

    if (rotCW)
{
    tramp1.rotation += 3;
    if (tramp1.rotation = 90){
        tramp1.rotation += 0;
    }
}

I'm trying to make it so that if the movieclip's rotation is 90, its rotation speed is 0.
But every time I press the ' key (which triggers rotCW), the movieclip's rotation just goes to 90.

Best Answer

your problem is assignment within the 2nd condition. you need to use "=="

if (rotCW)
{
    tramp1.rotation += 3;
    if (tramp1.rotation == 90){
        tramp1.rotation += 0;
    }
}

edit: the +=3 line you have executes regardless of angle. if you are passing 90 and dont want to, you can test for the opposite condition and increment in that case. eg: if less than 90.

if (rotCW)
{
    if (tramp1.rotation < 90){
        tramp1.rotation += 3;
    }
}
Related Topic