Jump to content
Search Community

synchronize Audio with animation Tweening with attachSound (as2)

duarteaugust test
Moderator Tag

Recommended Posts

Hi Jack!

 

I'm trying to synchronize sequence of audios obj_snd.attachSound("audio"+idAudio) and obj_snd.start(currentTween.position), with animation MyTimelineLite.append(TweenLite.to(obj_mc, 2 {_x:200, onStart:playAudio, onStartParams:[idAudio]})

Not found any topic about the issue and I think the greenSock (which is great) does not have native support this.

I need to detect whether a tween has audio attached, and moving the slideControl (drag slide) resynchronize the audio related to that tween.

(I think it would be something like onMidProgress:myFunc).

I think the logic is to detect the occurrence of an append (TweenLite. ..), his CurrentProgress and see if it passes onStart: PlayAudio, onStart: Params [idAudio] to synchronize ...

 

 

Other two questions:

1 - audios that last beyond the animation are not accounted for by the progressBar.

2 - I'm losing onStart event to position the marker of progress midle progress of a Tween.

 

Annex. simple .FLA

 

I appreciate any help, Thanks!

sinc_audio_tween.zip

Link to comment
Share on other sites

Hi I took a look at your file. Thank you for providing it.

 

I believe you are trying to use onStart to dictate which sound should play at a given point of your timeline. This will work only when forward progress is being made either by

 

1) the timeline naturally playing forward on its own

2) forward motion of the slider. if the user jumps from the middle of the first song to the middle of the second. Note you would have to set suppressEvents to false (second parameter in gotoAndPlay(), gotoAndStop())

 

in both situations the playhead will be jumping forward over a tween with an onStart callback.

 

If the user scrubs from the middle of tween2 to the middle of tween1 (backwards), Tween1's onStart will NOT fire. You need to determine the song previous to the timeline's current position.

 

on slider release you could use TimelineMax's getLabelBefore() method: http://www.greensock...getLabelBefore()

to determine which song should be playing at any point in time. You could then subtract the time of that label using getLabelTime("song1") from the currentTime of the timeline to determine where your soundObject should seek to.

 

soundSeekToPosition = timeline.currentTime - timeline.getLabelTime( timeline.getLabelBefore() );

 

getLabelTime() : http://www.greensock...l#getLabelTime()

 

You will have to add labels at the start of each tween and do a bit of tweaking but I imagine it is all roughly possible. I must note that Flash has never been strong with synchronizing sound AND TimelineLite/Max are not intended to drive sound sequences.

 

I'd encourage you to play with it, but keep your expectations reasonable.

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...