Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Actionscript 2 help needed on rotating movieclip

Guest
Sep 22, 2011 Sep 22, 2011

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.

TOPICS
ActionScript
5.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 22, 2011 Sep 22, 2011

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

...
Translate
LEGEND ,
Sep 22, 2011 Sep 22, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 22, 2011 Sep 22, 2011

Thank you sooooo much.  Exactly what i needed!  I will look into Actionscript tweening but it is a low priority for now.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 22, 2011 Sep 22, 2011
LATEST

You're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines