Stop and Play All Child MovieClips in Flash with Actionscript 3.0

I am stuck with the ActionScript here. I have a very complex animated flash movie for eLearning. These contain around 10 to 15 frames. In each frame I am having multiple movie clip symbols. The animation has been created using a blend of scripting and also normal flash animation.
Now I want to create pause and play functionality for the entire movie. I was able to create the pause function but when i try to play the movie it behaves very strange.
I was able to develop the pause functionality by refering to the below mentioned links:
http://www.unfocus.com/2009/12/07/stop-all-child-movieclips-in-flash-with-actionscript-3-0 /
http://www.curiousfind.com/blog/174
Any help in this regard is highly appreciated as i am approaching a deadline.
I am pasting the code below:
import flash.display.MovieClip;
import flash.display.DisplayObjectContainer;
import flash.utils.Timer;
import flash.events.TimerEvent;
import fl.transitions.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.events.Event;
import flash.events.MouseEvent;
stop();
// function to stop all movieclips
function stopAll(content:DisplayObjectContainer):void
    if (content is MovieClip)
        (content as MovieClip).stop();
    if (content.numChildren)
        var child:DisplayObjectContainer;
        for (var i:int, n:int = content.numChildren; i < n; ++i)
            if (content.getChildAt(i) is DisplayObjectContainer)
                child = content.getChildAt(i) as DisplayObjectContainer;
                if (child.numChildren)
                    stopAll(child);
                else if (child is MovieClip)
                    (child as MovieClip).stop();
// function to play all movieclips
function playAll(content:DisplayObjectContainer):void
    if (content is MovieClip)
        var movieClip:MovieClip = content as MovieClip;
        if (movieClip.currentFrame < movieClip.totalFrames) // if the main timeline has reached the end, don't play it
   movieClip.gotoAndPlay(currentFrame);
    if (content.numChildren)
        var child:DisplayObjectContainer;
        var n:int = content.numChildren;
        for (var i:int = 0; i < n; i++)
            if (content.getChildAt(i) is DisplayObjectContainer)
                child = content.getChildAt(i) as DisplayObjectContainer;
                if (child.numChildren)
                    playAll(child);
                else if (child is MovieClip)
                    var childMovieClip:MovieClip = child as MovieClip;
                    if (childMovieClip.currentFrame < childMovieClip.totalFrames)
      //childMovieClip.play();
      childMovieClip.play();
function resetMovieClip(movieClip:MovieClip):MovieClip
    var sourceClass:Class = movieClip.constructor;
    var resetMovieClip:MovieClip = new sourceClass();
    return resetMovieClip;
pauseBtn.addEventListener(MouseEvent.CLICK, onClickStop_1);
function onClickStop_1(evt:MouseEvent):void
MovieClip(root).stopAll(this);
myTimer.stop();
playBtn.addEventListener(MouseEvent.CLICK, onClickPlay_1);
function onClickPlay_1(evt:MouseEvent):void
MovieClip(root).playAll(this);
myTimer.start();
Other code which helps in animating the movie and other functionalities are as pasted below:
stage.addEventListener(Event.RESIZE, mascot);
function mascot():void {
// Defining variables
var mc1:MovieClip = this.mascotAni;
var sw:Number = stage.stageWidth;
var sh:Number = stage.stageHeight;
// resizing movieclip
mc1.width = sw/3;
mc1.height = sh/3;
// positioning mc
mc1.x = (stage.stageWidth/2)-(mc1.width/2);
mc1.y = (stage.stageHeight/2)-(mc1.height/2);
// keeps the mc1 proportional
mc1.scaleX <= mc1.scaleY ? (mc1.scaleX = mc1.scaleY) : (mc1.scaleY = mc1.scaleX);
stage.removeEventListener(Event.RESIZE, mascot);
mascot();
this.mascotAni.y = 100;
function mascotReset():void
// Defining variables
var mc1:MovieClip = this.mascotAni;
stage.removeEventListener(Event.RESIZE, mascot);
mc1.width = 113.45;
mc1.height = 153.85;
mc1.x = (stage.stageWidth/2)-(mc1.width/2);
mc1.y = (stage.stageHeight/2)-(mc1.height/2);
// keeps the mc1 proportional
mc1.scaleX <= mc1.scaleY ? (mc1.scaleX = mc1.scaleY) : (mc1.scaleY = mc1.scaleX);
var interval:int;
var myTimer:Timer;
// function to pause timeline
function pauseClips(secs:int, myClip:MovieClip):void
interval = secs;
myTimer = new Timer(interval*1000,0);
myTimer.addEventListener(TimerEvent.TIMER, goNextFrm);
myTimer.start();
function goNextFrm(evt:TimerEvent):void
  myTimer.reset();
  myClip.nextFrame();
  myTimer.removeEventListener(TimerEvent.TIMER, goNextFrm);
// function to pause timeline on a particular label
function pauseClipsLabel(secs:int, myClip:MovieClip, myLabel:String):void
interval = secs;
myTimer = new Timer(interval*1000,0);
myTimer.addEventListener(TimerEvent.TIMER, goNextFrm);
myTimer.start();
function goNextFrm(evt:TimerEvent):void
  myClip.gotoAndStop(myLabel);
  myTimer.removeEventListener(TimerEvent.TIMER, goNextFrm);
MovieClip(root).pauseClips(4.5, this);
// function to fade clips
function fadeClips(target_mc:MovieClip, next_mc:MovieClip, from:Number, to:Number):void
var fadeTW:Tween = new Tween(target_mc, "alpha", Strong.easeInOut, from, to, 0.5, true);
fadeTW.addEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
function fadeFinish(evt:TweenEvent):void
  next_mc.nextFrame();
  fadeTW.removeEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
// function to fade clips with speed
function fadeClipsSpeed(target_mc:MovieClip, next_mc:MovieClip, from:Number, to:Number, speed:int):void
var fadeTW:Tween = new Tween(target_mc, "alpha", Strong.easeInOut, from, to, speed, true);
fadeTW.addEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
function fadeFinish(evt:TweenEvent):void
  next_mc.nextFrame();
  fadeTW.removeEventListener(TweenEvent.MOTION_FINISH, fadeFinish);
// function to show screen transitions
function screenFx(target_mc:MovieClip, next_mc:MovieClip):void
//var tweenTW:Tween = new Tween(target_mc,"alpha",Strong.easeInOut,0,1,1.2,true);
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Iris, direction:Transition.OUT, duration:1.2, easing:Strong.easeOut, startPoint:5, shape:Iris.CIRCLE});
tranFx.addEventListener("allTransitionsOutDone",doneTrans);
function doneTrans(evt:Event):void
  next_mc.nextFrame();
  tranFx.removeEventListener("allTransitionsOutDone",doneTrans);
// function to show screen transitions inverse
function screenFxInv(target_mc:MovieClip, next_mc:MovieClip):void
var tweenTW:Tween = new Tween(target_mc,"alpha",Strong.easeInOut,0,1,1.2,true);
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Iris, direction:Transition.IN, duration:2, easing:Strong.easeOut, startPoint:5, shape:Iris.SQUARE});
tranFx.addEventListener("allTransitionsInDone",doneTrans);
function doneTrans(evt:Event):void
  next_mc.nextFrame();
  tranFx.removeEventListener("allTransitionsInDone",doneTrans);
// function to zoom in
function zoomFx(target_mc:MovieClip):void
//var tweenTW:Tween = new Tween(target_mc,"alpha",Strong.easeInOut,0,1,1.2,true);
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Zoom, direction:Transition.IN, duration:3, easing:Strong.easeOut});
//tranFx.addEventListener("allTransitionsInDone",doneTrans);
/*function doneTrans(evt:Event):void
  next_mc.nextFrame();
// Blinds Fx
function wipeFx(target_mc:MovieClip):void
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Wipe, direction:Transition.IN, duration:3, easing:Strong.easeOut, startPoint:9});
// Blinds Fx Center
function fadePixelFx(target_mc:MovieClip):void
var tranFx:TransitionManager = new TransitionManager(target_mc);
tranFx.startTransition({type:Fade, direction:Transition.IN, duration:1, easing:Strong.easeOut});
tranFx.startTransition({type:PixelDissolve, direction:Transition.IN, duration:1, easing:Strong.easeOut, xSections:100, ySections:100});

This movie is an animated movie from the start to end. I mean to say that though it stops at certain keyframes in the timeline it stops for only a certain time and then moves on to the next animation sequence.
Its not an application where the user can interact.
On clicking the play button i want the movie to play normally as it was playing before. If the user has not clicked on the pause button it would anyhow play from start to finish.
Is there anyway where i could send in the fla file?

Similar Messages

  • HT1725 I downloaded an album and all of the tracks will play about 3/4 of the song then stop and play the next song.  I went to itunes store and it said the songs fully downloaded. So how do I get the full song into my library?

    I downloaded an album and all of the tracks will play about 3/4 of the song then stop and play the next song.  I went to itunes store and it said the songs fully downloaded. So how do I get the full song into my library?

    If your country's iTunes Store allows you to redownload purchased tracks, I'd delete your current copies of the tracks and try redownloading fresh copies. For instructions, see the following document:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Otherwise, I'd report the problem to the iTunes Store.
    Log in to the Store. Click on "Account" in your Quick Links. When you're in your Account information screen, go down to Purchase History and click "See all".
    Find the items that are not playing properly. If you can't see "Report a Problem" next to the items, click the "Report a problem" button. Now click the "Report a Problem" links next to the items.

  • In Flex 3 how to Stop and Replay .swf animation created in Flash

    Hi
    I have an animation file that is created in Flash (I think
    CS3). In Flex if I import it inside a SWFLoader or if I import it
    as an Image. It plays once and stops. Then I can not replay it. I
    also can not pause it when its playing.
    I have tried few things based on help and code available in
    the Web to of no help. I have tried to convert the swfLoader
    instance to a movie clip like so to stop
    var c:MovieClip = swfLoaderHeaddress1.content as MovieClip;
    c.stop();
    <mx:SWFLoader x="53" y="116" width="206" height="255.3"
    visible="true"
    source="assets/animations/curatorial/ZoomHeadress_2nd.swf"
    id="swfLoaderHeaddress1"/>
    It does not work.
    I have not created the .swf animation, I am not sure how it
    is done. I belive it may not be using any ActionScript as I know
    the artist who created it does not know ActionScript. Does
    something need to be done inside the Flash to support the stop and
    play? Or is there a way to restart/replay stop a .swf animation in
    Flex 3 no matter how (and whether or not its developed using
    ActionScript) its developed in Flash?

    One way is she has to add some AS code to the animation, or
    you can do it yourself.
    In swf there must be something like this:
    var connReciever:LocalConnection = new LocalConnection();
    connReciever.client = this;
    connReciever.connect("fromFlexToSWF");
    function myFunction(parameter:SomeClass):void {...}
    And in Flex:
    var connSender:LocalConnection = new LocalConnection();
    connSender.send("fromFlexToSWF", "myFunction", [..args]);
    The other way: in case with just play/stop there is a way to
    resolve this by using that Flex Component Kit (or maybe "Flex Skin
    Design Extension", i do not remember), it is something like she
    just adding labels to animation frames then she exports it with
    Flex Kit and then you can work with it like with an object with
    "states".

  • How can I get iTunes to locate and play all my music files?

    How can I get iTunes to locate and play all my music files?

    I have this problem too. I am researching now. Here is what I know so far. If you right click a song then get ifo the it will say Protected AAC or purchased AAC. Protected wont play on sonos, purchased will play on sonos. It seems that all my protected were purchased 2005 to 2009 or so. I am trying to find out if apply will convert these for a small dfee or if I use the itunes cloud these tunes will convert for me. downloading and reloading is not an option for me. Pretty much a money grab by apple either way. I am sure Steve is smiling.

  • HT202157 My AppleTV (2nd gen) crashed last night with the latest update and now all I have a flashing light.  What to do?

    My AppleTV (2nd gen) crashed last night with the latest update and now all I have a flashing light.  What to do? It showed a USB symbol point toward an iTunes symbol and won't reset after resetting with the remote.  Same thing.

    usb symbol pointing toward an itunes symbol is apples way of trying to get you to connect the appletv to your computer running itunes so it can restore the apple tv's software
    though it seems to be a connection few people make

  • How do I get my music to quit scrolling and stop and play a song?

    How do I get my music to quit scrolling and stop and play a song?

    Basically it means that the files are not on the location where iTunes is expecting to be.
    What you can do is remove those songs from you playlist, then try to locate them on your harddisk again, and then in iTunes you can choose file > Add folder to Library... , specify the location where you found them and they will be added again.

  • Stop and play buttons...

    How would I go about adding stop and play buttons to a slideshow?
    stop1.addEventListener(MouseEvent.CLICK, stop1);
    play1.addEventListener(MouseEvent.CLICK, play1);
    function stop1(event:MouseEvent){
    if(this.currentFrame == 1)
    { gotoAndStop(this.totalFrames);
    function play1(event:MouseEvent){
    if(this.currentFrame == 1)
    { gotoAndStop(this.totalFrames);

    well idk if the code is even right i need help?  The way the slide show is working is i have it on the timeline....  With this code it doesnt play automatically and when i push play it goes through them in like 2 seconds and you can't see anything?
    stop1.addEventListener(MouseEvent.CLICK, stopSlide);
    play1.addEventListener(MouseEvent.CLICK, playSlide);
    function stopSlide(event:MouseEvent):void {
    stop();
    function playSlide(event:MouseEvent):void {
    play();

  • On Win 7 64 bit, Firefox 7, 8 and Nightly all refuse to see Flash. I have uninstalled, installed Flash 11 several times and FF just doesn't see Flash. Anyone got a fix?

    On Win 7 64 bit, Firefox 7, 8 and Nightly all refuse to see Flash. I have uninstalled, installed Flash 11 several times.

    There are two different versions of Flash, the '''''ActiveX''''' version for IE and the '''Plugin''' version used by most other browsers.
    1.Download the Flash Plugin version setup file from here: <br />
    [http://fpdownload.adobe.com/get/flashplayer/current/install_flash_player.exe Adobe Flash - Plugin version]. <br />
    Save it to your Desktop.<br />
    2. Close Firefox using File > Exit <br />
    then check the Task Manager > Processes tab to make sure '''firefox.exe''' is closed, <br />
    {XP: Ctrl+Alt+Del, Vista: Shift+Ctrl+ESC = Processes tab}
    3. Then run the Flash setup file from your Desktop.
    4. Start Firefox and test your installation here: https://www.adobe.com/software/flash/about/
    * On Vista and Windows 7 you may need to run the plugin installer as Administrator by starting the installer via the right-click context menu if you do not get an UAC prompt to ask for permission to continue (i.e nothing seems to happen). <br />
    See this: <br />
    [http://vistasupport.mvps.org/run_as_administrator.htm]

  • Podcasts stops and plays a previous one

    In my itunes (latest update), my podcasts randomly stop and played the previous episode. This patterns seems random as well. I don't download podcasts, but stream them (right click, play). However, when I download the podcast and play it, its fine. But I would rather stream it.
    Also, my internet is fine. I am on blazing fast university internet.
    Does anyone have a fix for this?

    delete off any apps that are asking for the wrong apple id and download/sync them over from the correct one

  • Creating chapters and play all

    hi, i have a concert film. i recorded all the footage in by song, so i have 12 5+ minute files. I want to make a play all function, so the dvd will just play each song right after the ones before it. basically, how do i make each song a chapter and play all capabilities. i already made it so each song is its own film, but once the song ends, it retunrs to the menu....

    In iMovie or iDVD, you can edit the songs one after the other in the same timeline to create one movie. Drop that movie into iDVD and you will get a movie that plays the songs in sequence. Also, in iDVD, you can a chapter for each song to give viewers the options of going to each one
    With the lengths you are dealing with, you could still put each song as a separate movie into your DVD is you so choose

  • Can we and should we renew the adobe flash with the new Safari download?iobove flasd;nd

    can we and should we renew the adobe flash with the new Safari download the got rid of it?

    The Flash plug-in is not deleted when you upgrade Safari. But in any event you should use the most recent compatible version of Flash - Download version 10.3.183.19 for Mac OS X 10.4 - 10.5 (6.1MB) - for your version of OS X.

  • Some songs starts on my iPod, then stop and start from the begining and play all the way through

    Hey,
    While listening to songs on my iPod Classic 120gb, some songs will start to play, after 2-3 seconds, stop and start again from the beginning and play through the entire song no problems. On iTunes the songs still plays fine no stopping or starting. All songs are random artists and songs.
    Help! its really frustrating!

    Hey andy8299,
    Do you have any other music software (i.e Limewire) installed? If so perhaps these files are not compatible.
    See this for compatible song formats:
    http://docs.info.apple.com/article.html?artnum=61476
    Hope this helps,
    Generik

  • Simple Stop and Play

    I have been trying to create a very simple slideshow for a
    friends site I done for him to advertise his
    business. The photos,
    I suggested would be better if they were done as a slideshow and
    the idea was to have each picture fade in, stop, click to play,
    fade out fade in next, stop, etc etc.
    I have tried every tutorial I can find and done most of the
    things in the Visual Quick Start Guide Macromedia Flash 8 and still
    I cannot get it to work. All I really want is to stop, click and
    play at each point along the timeline at regular points.
    Can anyone please help me with this. The .fla I am working on
    can be found
    here
    Any help will be greatly appreciated as I am running out of
    hair left to pull out.
    Nig

    I have made changes to your file. It now works as you want.
    Email me so I can send it to you.
    chosenson Please reference
    this post in the subject line.
    Thanks

  • Making stop and play functions fool-proof

    I have a timeline control embedded into my flash piece. It
    contains the buttons "Re-Play, Pause, and Play." I am building some
    testing software, therefore I have instances where the
    animation/sound stops and waits for the user to select an answer.
    At first, I had a problem that, when the user would come to a
    stop point, they could simply click the play button and the audio
    would continue (the play button simply held a command like this):
    on (press) {
    play();
    So I changed it to an IF statement that looked for a variable
    before the PLAY button could be pressed. It looks like this:
    MP3Player, Frame 1
    set ("operator",1);
    Play Button
    on (press) {
    if (operator==1) {
    if (operator==2) {
    play();
    set ("operator",1);
    Pause Button
    on (press) {
    stop();
    set ("operator",2);
    It shows that, in order for Play to work, the user must first
    PAUSE the flash piece.
    The problem therein is that if the user comes to a stop in
    the timeline, they can simply click PAUSE and then PLAY and
    continue on the MP3Player element without advancing any of the
    animation. Is there anyone who can help me fix this? Thanks!

    Sorry - yeah you're right i didn't think that through
    completely. Use the code I suggested though, and add more code
    elsewhere. at the moment operator has two states, yeah? 1=playing,
    2=paused. You could introduce a third state - 3=quiz(or whatever's
    going on in your application).
    So wherever you have your stop() action on a frame, add the
    line:
    operator=3;
    and where the user selects their answer(i am assuming the
    animation continues on at this point?) and you have a play()
    action, add the line:
    operator=1;
    this should give you what you're asking for. the fleece does
    have a point though, that it would make sense to remove the
    play/pause buttons altogether during the quiz as they are inactive
    anyway.
    Craig

  • X2: How to stop and play a MP3 file from any place...

    Hi,
    I have some 1 hour talk shows on MP3 on my X2. I play one show. After 10 minutes I want to pause it there and take a call, or go to the menu and add a reminder, and come back to the mp3 and play from the point I stopped (10 minutes). How to do that? 
    When I pause and come back and press play, it starts from the begininging????
    Thanks
    Roahan

    Well a smarter way of implementing this is by using a solution provided by Java Itself.
    If you are using J2SE 6.0+ there is an in built solution provided along with JDK itself and inorder to go ahead with solution the below are set of API which you;d be using it for compiling Java Programs (Files)
    http://java.sun.com/javase/6/docs/api/javax/tools/package-summary.html
    How do i do that ??
    Check out the below articles which would help you of how to do that
    http://www.ibm.com/developerworks/java/library/j-jcomp/index.html
    http://www.javabeat.net/javabeat/java6/articles/java_6_0_compiler_api_1.php
    http://books.google.com/books?id=WVbpv8SQpkEC&pg=PA155&lpg=PA155&dq=%22javax+tools%22+compiling+java+file&source=web&ots=XOt0siYe-f&sig=HH27ovuwvJgklIf8omTykUmy-eM
    Now once we are done with compilation.In order to run a Specific class all you ought to do is create an object and its specific methods of a specified class included in the CLASSPATH which you can manage it easily by usage little bit reflections.
    Hope that might help :)
    REGARDS,
    RaHuL

Maybe you are looking for

  • How to put Video/DVD/games/eBook to Nokia

    Nokia phone still the NO.1 of all the phones, As a fan to Nokia phone, I want to share with you some tips to play Nokia. Only some experience of play Nokia phone, just enjoy it. This guide will show you how to put videos to Nokia, DVD to Nokia, games

  • Windows Error Msg when using Itunes - "There is no disk in the drive. "

    Hi there - Desperately seeking help before I lose my mind ! Whenever I try to do anything in iTunes I get the Windows windows error message "WINDOWS - NO DISK. There is no disk in the drive. Please insert a disk into drive ." with the options to eith

  • Letter of Credit in Export

    Dear All, Can anybody help me with the config guide for Letter of Credit in Export Sales. Points shall be awarded for the best resolution. Best Regards, Indrajit

  • MuseJSAssert Error

    Recently update from CS6 to CC.  Site on GoDaddy has error MuseJSAssert Error: error calling selector function: Error "webPro" is not defined.  I have upload all pages, as well as published HTML and uploaded entire site with Dreamweaver with same res

  • Duplex printing on Canon i860

    I have a Canon i860 printer which I have had for a couple of years and have loved it. But since I upgraded a little over a year ago from a Lombard PB running OS 9.1.1 to a G4 iBook running OS 10.4 in its various incarnations I have not been able to p