Jump to content
Search Community

How to detect if a Timeline is Paused?

rob_v_5712 test
Moderator Tag

Recommended Posts

I have a swf (1.swf) where the animation is controlled using timelineLite.

 

That swf is played inside another swf (player.swf).  The player.swf can play and pause 1.swf.

 

 

Inside 1.swf I create the timeline using this :

myTimeline =  new TimelineLite( {onUpdate:checkIfPlaying} );

 

So inside that checkIfPlaying function - I can tell if the timeline is playing.  What Im having issues with is how can I tell when the timeline get paused?

 

I tried testing for myTimeline.paused() inside the checkIfPlaying function - but that function is only executed while the timeline is actually playing.  Is there any type of event that is fired when its paused? 

 

Thanks for any help.

 

=Rob

 

 

 

 

 

Link to comment
Share on other sites

In order to ensure GSAP has blazing fast performance, it doesn't fire events on every action it takes, so there's no 'pause' event to listen for.

 

There's always the line after you call sometimeline.pause() to alert your parent swf... You could try dispatching your own events when they're required after a pause(), and listen for those. Here's a very basic intro I found from a quick google, but I'll trust that you can google for more in-depth information and APIs.

  • Like 1
Link to comment
Share on other sites

The sometimeline.pause() is happening inside the player.swf file.

Its actually grabbing the 1.swf timeline object and doing a pause() on it.

 

The player.swf plays swfs in their own container (context = separate) my understanding being that the player.swf can see "items" in the 1.swf - but not the otherway around.  (1.swf has no knowledge of data or detection of actions w/in player.swf)

 

Also - lets assume for this case, I cannot modify player.swf.

 

The end game here is this.

1.swf has a timelime object.  It also loads an MP3 file and plays it.

 

 

When player.swf fires, it loads 1.swf and can play it, it can also pause it.  The issue I'm having is I cannot pause/resume the audio when I play/pause the 1.swf from player.swf.

 

Looking into a few other options to do this...I noticed MP3Loader.PLAY_PROGRESS, i may try checking in there if the timeline is paused and if so - then pause the sound.

 

Always open to suggestions.

 

Thanks

Link to comment
Share on other sites

You really can't modify the player at all?

* It would be very simple to implement a play/pause function in the child that controlled both the timeline and the sound, and call that from the player instead of only targeting the timeline:

// Player

child.pauseAll();
// Child

public function pauseAll() {
  sometimeline.pause();
  someAudio.pause();
}

public function playAll() {
  sometimeline.play();
  someAudio.play();
}

* You could try extending TimelineLite and adding what you need to the pause() function.
 
* Maybe you could move your checkIfPlaying to the TweenLite ticker, so you'll still get events when it's paused i.e.

TweenLite.ticker.addEventListener("tick", checkIfPlaying);
  • Like 2
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...