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

Rotate a Duplicated Movieclip

New Here ,
May 04, 2013 May 04, 2013

I am trying to finish a small project and am having trouble continuosly rotating a duplicated movieclip via a button. It will rotate by clicking the button; however, I have it set to 7.5 degrees and a complete rotation takes quite a while. We would like to just click and hold to rotate it. Once the button is released it would stop. Any help would be very much appreciated. My code is below:

MovieClip (myMC):

on (press) {

           startDrag("", false);

}

on (release) {

           stopDrag();

}

on (release) {

           setProperty("/rotate", _name, "");

           setProperty("", _name, "rotate");

}

Rotate Button:

on (press) {

           ChangeRotation = getProperty("/rotate", _rotation);

           setProperty("/rotate", _rotation, Number(ChangeRotation) -7.5);

}

Button used to Duplicate the movieclip:

on (release) {

   _root.myMC.duplicateMovieClip ("myMC_"+ "x",this.getNextHighestDepth());

   setProperty ("myMC_"+"x", _x, 585);

   setProperty ("myMC_"+"x", _y, 400);

   x++;

}

TOPICS
ActionScript
641
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 ,
May 04, 2013 May 04, 2013

Initiate an onEnterFrame function when the rotate button is pressed and delete it when that button is released.  Have the onEnterFrame processing handle the change in rotation value.

The onEnterFrame function executes at the frame rate of your file, so whatever processing you put in the function for it executes continuously.

You should consider moving up to AS2 at least for your coding.  It will reduce your code and bring you one step closer to modern Flash programming.  And you should get the code off of the objects and place it in the timeline instead.

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
New Here ,
May 05, 2013 May 05, 2013

Thank you for your help Ned. I saw a sample file for a rotation that included the onEnterFrame but honestly I am far from a computer programmer. In fact, I've pretty gotten where I am by searching and manipulating other files.

That being said, I am really not sure how exactly to adapt the function to the buttons/movieclips that are duplicated.

If not too much of an inconvenience, would it be possible to ask for a little assistance? I've gotten to a point where everything functions well but am just trying to tighten it up a little.

Thanks again for your time.

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 ,
May 05, 2013 May 05, 2013

Here's a link to a sample file I made to show you how to use the onEnterFrame to make the object spin while you press the button.  Notice how the code is in the timeline rather than on the objects, and how the properties are assigned directly rather than using setProperty...

http://www.nedwebs.com/Flash/AS2_spinMC.fla

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
New Here ,
May 07, 2013 May 07, 2013
LATEST

Hi Ned, thank you very much for the help. I can't seem to get it to work though. Possibly because I am trying with a duplicated movieclip. I need to get this completed by the end of the week. May I contact you directly and we can discuss this further? I understand your time is valuable and would be willing to discuss that portion as well.

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