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

How to play parts of a movie clip with AS3 and or TweenMax

Contributor ,
Sep 09, 2011 Sep 09, 2011

Suppose a MovieClip in as3 call myClip is 100 frames long and has labels at the following frames:

0-start; 25-early; 50-mid; 75-late; 100-end

Can someone explain (either using regular AS3 or with Greensock's TweenMax or TimelineMax) how to make my myClip play frames 0 to 25 then back to 0 again, and frames 100 to 75 and back to 100,  Ideally would be able to loop over those ranges during a mouse ROLL_OVER event.

I'm pretty sure this can be done through Greensock's Tweening and Timeline platform, but can't quite get it working.

Thanks for any assistance.

TOPICS
ActionScript
2.0K
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
Participant ,
Sep 09, 2011 Sep 09, 2011

Im not sure exactly what you are asking of, But you could have buttons so when the button is pressed it plays the 25 frames or so...

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 09, 2011 Sep 09, 2011

Using regular AS3 you could use an Event.ENTER_FRAME listener and have it call a function that uses either nextFrame() or prevFrame() function calls to move along the timeline.  Each call could be preceded by a test to see if the destination frame == currentFrame, and when it does you remove the ENTER_FRAME listener

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
Contributor ,
Sep 09, 2011 Sep 09, 2011

Thanks for the replies.

I saw the ENTER_FRAME method for doing this on a couple of google searches.  Is there a way to make the MovieClip play in reverse with standard actionscript 3 - so if I can start at frame 0, go to frame 25, and then back to frame 0 when one button is rolled over, and from 100 to 75 and back to 100 for a different rollover?

I'm also pretty sure you can do this in a simpler fashion with Greensock's Tweenmax and / or TimelineMax.  I'll try those forums as well.  Do appreciate the help here as well.  Thanks.

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 10, 2011 Sep 10, 2011
LATEST

For backwards playing of an animation, you could always animate it that way. If you need an animation to loop within the timeline, you could simply add labels to frames and on the frame you desire tell it to gotoAndPlay(label).

However, if you need specifically to be able to play it forward and backward, then I would use what Ned said.

I am not sure you could do this within the timeline, you'd need to do this through AS3 class, by adding a ENTER_FRAME event that either told the MovieClip to do nextFrame() or prevFrame() depending on what you choose.

For example...

private const FORWARD:int = 0;

private const BACKWARD:int = 1;

private var action:int;

public function Constructor()

{

     this.addEventListener(Event.ENTER_FRAME, animateMovieClip);

}

private function animateMovieClip(e:Event):void

{

     switch (action)

     {

          case FORWARD:

               this.nextFrame();

               break;

          case BACKWARD:

               this.prevFrame();

               break;

     }

}

public function setAction(pAction:int):void

{

     this.action = pAction;

}

This requires more logic, depending on your needs. However, I hope this gets you in the right direction.

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