-
Ignore stop command in child MC
I have created a file which has play & pause playback controls which control the soundchannels and the child movieclips of the container. The playback controls work fine for the soundchannels and the movieclips but if you add a movieclip with a stop command on the end of it, when the movieclip reaches the end it stops as expected but as soon as you click the play/pause button it restarts.
Is there anyway to prevent this?
Code below:
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.events.MouseEvent;
import flash.display.MovieClip;
//Playback button properties
pause_btn.visible = true;
pause_btn.buttonMode = true;
play_btn.visible = false;
play_btn.buttonMode = true;
//SoundChannel init
var mySound:Sound = new sample();
var myChannel:SoundChannel = new SoundChannel();
var lastPosition:Number = 0;
myChannel = mySound.play();
//Pause button
pause_btn.addEventListener(MouseEvent.CLICK, onClickPause);
//Pause sound function
function onClickPause(e:MouseEvent):void{
lastPosition = myChannel.position;
myChannel.stop();
pauseMovieClip(container);
pause_btn.visible = false;
play_btn.visible = true;
}
//Pause MovieClips function
function pauseMovieClip(mc:MovieClip):void{
for (var i:int = 0; i < mc.numChildren; i++){
var mcChild = mc.getChildAt(i);
if (mcChild is MovieClip){
mcChild.stop();
}
}
}
//Play button
play_btn.addEventListener(MouseEvent.CLICK, onClickPlay);
//Play sound function
function onClickPlay(e:MouseEvent):void{
myChannel = mySound.play(lastPosition);
playMovieClip(container);
pause_btn.visible = true;
play_btn.visible = false;
}
//Play MovieClips function
function playMovieClip(mcPlaying:MovieClip):void{
for (var j:int = 0; j < mcPlaying.numChildren; j++){
var mcPlay = mcPlaying.getChildAt(j);
mcPlay.play();
}
}
And the .FLA
http://www64.zippyshare.com/v/71628265/file.html
-
Try putting this inside the play button's function:
if ( movieclipname.currentFrameLabel != "last" ){
movieclipname.play();
}
Then inside the movie clip you made, name the very last frame "last."
If your movie clip has multiple stopping points, you can use multiple frame labels or just use .currentFrame and the actual number if you do not plan on changing them.
Hope that helps
-
Originally Posted by Fleetatks
Try putting this inside the play button's function:
if ( movieclipname.currentFrameLabel != "last" ){
movieclipname.play();
}
Then inside the movie clip you made, name the very last frame "last."
If your movie clip has multiple stopping points, you can use multiple frame labels or just use .currentFrame and the actual number if you do not plan on changing them.
Hope that helps
Hi Fleetatks,
That's exactly what I was looking for. The only tweak I made was it could could read any child movieclip with the last frame label set to "last" rather than just one movieclip. Thanks for all your help
Phil
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|