Copy link to clipboard
Copied
Hi,
I need some advice.
I have a tween, which is rotating the (MovieClip01) and playing a sound on the same time.
The sound is a song, 7.2 seconds long.
rotationTween = new Tween(this, "rotation", None.easeIn, 0, 2880, 7.5, true);
When another animation starts (MovieClip02), also with sound, the sound for MovieClip01 is stopped. In order not to have mix and also to save some memory, as the second animation is quite big.
In case the second animation is stopped (animation and sound), but the first one still lasting, I would like the sound of the first MovieClip01 to start playing again. But not from beginning, but from the place where the Tween is at that point of time.
I could just mute the sound for the first animation and then unmute, but that wouldn't free up the memory.
And so my question - how to find the current position of the tween to use it for calculating the place from where the sound should start playing again?
I thought to stop the rotation tween at that moment, take the rotation value and use it for calculating the starting position for the sound.
But the rotation value seems to be between -180 and 180.
rotationTween.stop();
curRotation = this.rotation;
trace("curRotation is " + this.rotation);
Many thanks in advance!
Copy link to clipboard
Copied
store your soundchannel's position in a variable when you're stopping it and use that variable in your sound's play method to restart at the correct offset.
Copy link to clipboard
Copied
but wouldn't that start the sound from the place it was stopped?
The animation of the MovieClip01 has been playing in meanwhile.
So the audio should skip a part of the track and not start from where it was stop, but a bit later.
How to find that spot?
Copy link to clipboard
Copied
yes, that would start it where it was stopped. if the movieclip is continuing to play you can use an approximation to find the offset:
var ms:int = int(1000*(yourmovieclip.currentFrame-yourmovieclip_startframe)/stage.frameRate);
Copy link to clipboard
Copied
Yes, but when the animation is done using a tween.
It has only one frame. Or?
I used tween, as it takes less memory compared to enterFrame.
Copy link to clipboard
Copied
then use a tween update listener.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now