Copy link to clipboard
Copied
I need help with the "stopping" of a movieclip rotation. I think this would be easy for you Flash gurus but impossible for me.
Here is the description. The code below shows a movieclip rotating after mouse click but i want it to stop in place after 60 degrees. Basically I need it to rotate 60 degrees after every mouse click and stop. The "trace" function is there so i know something will happen when it rotates a certain degree. Right now it rotates continually after the mouse click.
mc.onRelease=function(){
mc.onEnterFrame=function(){
mc._rotation=mc._rotation+=10;
if(mc._rotation==60){
trace("HIT");
}
}
}
As a bonus i would like the rotation of every 60 degrees to ease in and out. Thank you in advance for any help you can give me.
When the _rotation value reaches the 60 degree mark, you need to delete the onEnterFrame delete mc.onEnterFrame;.
There is only one position where the _rotation value will == 60, so if the intention is to stop it at every 60 degrees, then you'll need to change the conditional to be...
if(mc._rotation%60==0){
So....
mc.onRelease = function(){
mc.onEnterFrame = function(){
mc._rotation = mc._rotation+=10;
if(mc._rotation%60==0){
trace(mc._rotation);
delete
...Copy link to clipboard
Copied
When the _rotation value reaches the 60 degree mark, you need to delete the onEnterFrame delete mc.onEnterFrame;.
There is only one position where the _rotation value will == 60, so if the intention is to stop it at every 60 degrees, then you'll need to change the conditional to be...
if(mc._rotation%60==0){
So....
mc.onRelease = function(){
mc.onEnterFrame = function(){
mc._rotation = mc._rotation+=10;
if(mc._rotation%60==0){
trace(mc._rotation);
delete mc.onEnterFrame;
}
}
}
If you want to have easing, I suggest looking into using Actionscript tweening. With steps of 10 there's little room to ease.
Copy link to clipboard
Copied
Thank you sooooo much. Exactly what i needed! I will look into Actionscript tweening but it is a low priority for now.
Copy link to clipboard
Copied
You're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now