Jump to content
Search Community

Problem "Pausing/Resuming" Tween

yvette watson test
Moderator Tag

Recommended Posts

Hello All

 

I'm relatively new to Flash and Greensock and thank you in advance for your patience and assistance. The code below is for a slideshow. The movieclip slides and fades in and out and then goes to the next frame. I want the play and pause buttons to "pause/resume" the tween but it just goes to the next frame.

 

Thank you

 

 

 

import com.greensock.*;//imports greensock TweenEngine

import com.greensock.easing.*;

import com.greensock.plugins.TweenPlugin;

import com.greensock.plugins.FramePlugin;

 

 

 

stop();

 

 

 

 

//: Variables =========================

 

 

//adds images dynamically

var intro_mc:g1_intro_mc = new g1_intro_mc();

addChild(intro_mc);

intro_mc.x=-intro_mc.width; intro_mc.y=4; intro_mc.alpha=0;

 

 

 

//: Functions =========================

 

 

var fadesIn_1:TweenLite = new TweenLite(intro_mc, 2, {delay:3,alpha:1, x:4, y:4,onComplete:fadesOut_1});

var fadesOut_1:TweenLite = new TweenLite(intro_mc, 2, {delay:11,alpha:0, x:stage.stageWidth, y:4, onComplete:nxt2, overwrite:false});

 

function nxt2():void {removeChild(intro_mc);gotoAndPlay("2");}

 

 

//Button EventListeners

pause_btn.addEventListener(MouseEvent.CLICK, navPause);

play_btn.addEventListener(MouseEvent.CLICK, navPlay);

 

 

//Button Functions

function navPause(event:MouseEvent):void { fadesIn_1.pause(); trace(intro_mc);}

function navPlay(event:MouseEvent):void { fadesOut_1.resume(); trace(intro_mc);}

Link to comment
Share on other sites

currently navPause tells fadesIn_1 to pause(), but it doesn't have any control over fadesOut_1. fadesOut1 has an 11 second delay. pausing fadesIn_1 doesn't stop fadesOut_1 from playing.

 

I imagine that is your problem.

 

also, are you using similar code on every frame? do you have fadesIn_2 and fadesOut_2 tweens on frame 2? If so, you probably want to find another way of approaching this. It will be very difficult to troubleshoot or add new features if you are repeating code over and over in multiple frames.

 

 

instead of jumping around to different frames on the main timeline, you could put all of your images into a single movie clip side by side. when you click the next button, you could run some commands that:

 

1: fade out the movie clip that contains all the images.

2: change its x position so that the next slide is in position

3: fade the movie clip back in

 

Just an idea.

Link to comment
Share on other sites

Thank you so much!! Worked like a charm and incredibly simple.

 

Yes. I have repeating code on each frame—I saw an example of a slideshow you described ie. images side by side instead of on separate frames. I'll need to look at it again, if you think it's a better solution. Thank you again for your help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...