Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-28-2012, 03:59 PM   #1
shelleyh
Registered User
 
Join Date: Apr 2011
Posts: 10
Default Move tween back and forward

I am trying this simple animation but I am unable to get it right. I want my movie clip to move forward and backward and stop at a point for each button. Buttons 1-5 each have a stopping point.

I attached the file.

Basically, if I click 4, I want the playhead to move to that frame either back or forward, depending on where it is. Here is the code that doesn't work:

ActionScript Code:
stop(); step1_btn.addEventListener(MouseEvent.CLICK, step1); step2_btn.addEventListener(MouseEvent.CLICK, step2); step3_btn.addEventListener(MouseEvent.CLICK, step3); step4_btn.addEventListener(MouseEvent.CLICK, step4); step5_btn.addEventListener(MouseEvent.CLICK, step5); function step1(e:Event):void {     if (currentFrame <= 1 && currentFrame > 121) {         prevFrame();      } else {         stop();     } } function step2(e:Event):void {     if (currentFrame < 21 && currentFrame > 101) {         prevFrame();     } else if (currentFrame <= 1 && currentFrame > 19){         play();     } else {         stop();     } } function step3(e:Event):void {     if (currentFrame < 41 && currentFrame > 101) {         prevFrame();     } else if (currentFrame <= 1 && currentFrame > 39){         play();     } else {         stop();     } } function step4(e:Event):void {     if (currentFrame < 61 && currentFrame > 101) {         prevFrame();     } else if (currentFrame <= 1 && currentFrame > 59){         play();     } else if (currentFrame == 60){         stop();     } } function step5(e:Event):void {     if (currentFrame < 81 && currentFrame > 101) {         prevFrame();     } else if (currentFrame <= 1 && currentFrame > 79){         play();     } else {         stop();     } }

I really need some help please! I have tried many methods and none are working for me.
Attached Files
File Type: zip index.fla.zip (229.0 KB, 38 views)

Last edited by shelleyh; 04-28-2012 at 04:03 PM.
shelleyh is offline   Reply With Quote
Old 04-28-2012, 08:08 PM   #2
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,411
Default

TweenMax can move the playhead forward or backward very easily.
http://www.greensock.com/as/docs/tween/_tweenmax.html
[afz]snickelfitz is offline   Reply With Quote
Old 04-28-2012, 09:34 PM   #3
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 3,160
Send a message via AIM to Mazoonist
Default

Snickelfitz,

I don't know if you downloaded and/or looked at the file, but shelleyh here is using Flash's timeline for the tweens. I don't think TweenMax can tween Flash's playhead, or can it? You seem to be saying so, but I think you mean that TweenMax can easily tween its OWN playhead for a given tween.

shelleyh,

So, I too would recommend doing scripted tweens using TweenMax, as it's much easier to do effects like reversing the playback. But to do so, you would have to give up your current approach of using Flash's timeline to do your animations. For example, instead of using Flash's timeline to make your blueIndicator object expand and contract, you would get rid of the timeline tween, and just use TweenMax to tween its width.

Also, the reason your code isn't working is because your code is inside the menu_mc MovieClip, but all your buttons are one level up in the main timeline. You have to either provide the correct path to the buttons, or (better) move the code to the main timeline so that it's in the same scope as the buttons.
__________________
My Tutorials * My Website
Mazoonist is offline   Reply With Quote
Old 04-28-2012, 10:19 PM   #4
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,411
Default

Yeah, TweenMax can move the playhead within a MovieClip with the "frame" property.
Can be used to alter the duration of a timeline tween, make it "yoyo", loop a specific number of times, run backwards, etc...
Another useful feature is the ability to call methods at the start and/or end of the tween.
[afz]snickelfitz is offline   Reply With Quote
Old 04-28-2012, 10:21 PM   #5
dmb85
Senior Member
 
Join Date: Jan 2012
Posts: 608
Default

Quote:
Originally Posted by Mazoonist View Post
Snickelfitz,

I don't know if you downloaded and/or looked at the file, but shelleyh here is using Flash's timeline for the tweens. I don't think TweenMax can tween Flash's playhead, or can it? You seem to be saying so, but I think you mean that TweenMax can easily tween its OWN playhead for a given tween.
No, snickelfitz is correct - TweenMax can tween a movieclip's timeline back and forth via FramePlugin.
dmb85 is offline   Reply With Quote
Old 04-28-2012, 10:34 PM   #6
Mazoonist
Site Contributor
 
Mazoonist's Avatar
 
Join Date: Jun 2006
Posts: 3,160
Send a message via AIM to Mazoonist
Default

Okay, just checked it out. I guess I am giving away that I have been neglecting the greensock library, or I would have known.

Anyway, yeah, the property is either frameForward or frameBackward, not frame, and it does indeed work if you activate the plugin(s), which are the FrameForwardPlugin and the FrameBackwardPlugin.
__________________
My Tutorials * My Website
Mazoonist is offline   Reply With Quote
Old 04-28-2012, 11:11 PM   #7
[afz]snickelfitz
Senior Member
 
[afz]snickelfitz's Avatar
 
Join Date: Dec 2011
Location: Tucson, AZ
Posts: 2,411
Default

Interesting, I've always used frame; maybe an update I haven't downloaded.
frame still works though.
ActionScript Code:
import com.greensock.*; TweenMax.to(mc, 1, {frame:mc.totalFrames, yoyo:true, repeat:-1});
[afz]snickelfitz is offline   Reply With Quote
Old 04-29-2012, 02:44 PM   #8
shelleyh
Registered User
 
Join Date: Apr 2011
Posts: 10
Default

Well, I don't know anything about TweenMax but I seemed to get this working:
ActionScript Code:
import com.greensock.*; import com.greensock.easing.*; stop(); menu_mc.step1_btn.addEventListener(MouseEvent.CLICK, step1); menu_mc.step2_btn.addEventListener(MouseEvent.CLICK, step2); menu_mc.step3_btn.addEventListener(MouseEvent.CLICK, step3); menu_mc.step4_btn.addEventListener(MouseEvent.CLICK, step4); menu_mc.step5_btn.addEventListener(MouseEvent.CLICK, step5); function step1(e:Event):void {     TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.09}); } function step2(e:Event):void {     TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.3}); } function step3(e:Event):void {     TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.5}); } function step4(e:Event):void {     TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.71}); } function step5(e:Event):void {     TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.93}); }

The only problem I'm having is that if I go straight from step 1 to step 5 it goes faster than from step 1 to 2 because the amount of seconds. I can live with that.
shelleyh is offline   Reply With Quote
Old 04-29-2012, 04:06 PM   #9
shelleyh
Registered User
 
Join Date: Apr 2011
Posts: 10
Default

I've changed to this because I needed to add a function to move the main timeline so the content can change.

Thanks for the help.

ActionScript Code:
import com.greensock.*; import com.greensock.easing.*; import flash.events.Event; stop(); menu_mc.step1_btn.addEventListener(MouseEvent.CLICK, stepSelection); menu_mc.step2_btn.addEventListener(MouseEvent.CLICK, stepSelection); menu_mc.step3_btn.addEventListener(MouseEvent.CLICK, stepSelection); menu_mc.step4_btn.addEventListener(MouseEvent.CLICK, stepSelection); menu_mc.step5_btn.addEventListener(MouseEvent.CLICK, stepSelection); function stepSelection( pEvent:MouseEvent):void {     if( pEvent.target == menu_mc.step1_btn )     {         TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.09,onComplete:this.gotoAndStop,onCompleteParams:["step1"]});     }     if( pEvent.target == menu_mc.step2_btn )     {         TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.3,onComplete:this.gotoAndStop,onCompleteParams:["step2"]});     }     if( pEvent.target == menu_mc.step3_btn )     {         TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.5,onComplete:this.gotoAndStop,onCompleteParams:["step3"]});     }         if( pEvent.target == menu_mc.step4_btn )     {         TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.71,onComplete:this.gotoAndStop,onCompleteParams:["step4"]});     }     if( pEvent.target == menu_mc.step5_btn )     {         TweenMax.to(menu_mc.bar_mc, 1.5, {scaleX:0.93,onComplete:this.gotoAndStop,onCompleteParams:["step5"]});     } }
shelleyh is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:57 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.