How to stop a movie clip that is loaded dynamically

Hello Flash Forum,
I am using the loadmovie method to load a swf file into a
movie clip "container"
Code snippet:
var mc:MovieClip = this.createEmptyMovieClip("mc",1);
mc.loadMovie('bbc_module1.1.swf','bbc_audio',container.getNextHighestDepth(),
{_x:300.8, _y:240});
mc._lockroot = true;
The movie clip I load does not have a stop action in frame 1,
but comes up playing (audio and images). I am not using video. It
is a series of still images synced to the audio.
I would like to be able to load the movie clip, stop it from
playing, and by clicking buttons, get it to play, pause, etc like
the buttons and skin on the FLVPlayer.
Any tips on how to do this?
Thanks,
eholz1

Many thanks ClBeech!!!
I've tried the code you suggested but it doesn't seem to work
:0(
I'm working on a Mac using Flash Pro 8 which only has the
option to publish as 'actionscript 1.0 or 2.0' is the script you
supplied an actionscript 3.0?
Below is the script with the amendments, I've changed my
button instance names to match the script you supplied (left_btn /
right_btn)
stop();
import mx.transitions.Tween;
import mx.transitions.easing.Strong;
var rposX = 369;
//the ending x of the right position
var rposY = 84;
//the ending y of the right position
var lposX = 116;
//the ending x of the left position
var lposY = 154;
//the ending y of the left position
right_btn.onPress = function() {
new Tween(content1, '_x', Strong.easeOut, content1._x,
rposX, time, false);
new Tween(content1, '_y', Strong.easeOut, content1._y,
rposY, time, false);
left_btn.onPress = function() {
new Tween(content1, '_x', Strong.easeOut, content1._x,
lposX, time, false);
new Tween(content1, '_y', Strong.easeOut, content1._y,
lposY, time, false);

Similar Messages

  • How to stop a movie clip moving

    I'm not newbie to flash but I am newbie to coding using
    actionscript!!!
    I am trying to create a button that moves a movie clip
    ("content1") diagonally across the screen but once the movie clip
    reaches a certain x co-ordinate I want it to stop and then when I
    click another button I would like it to return to it's starting
    position. At the moment the movie clip moves if I click one of the
    buttons but as soon as I click another one it stops which it
    shouldn't it should go back in the other direction. The other
    problem is that once I've clicked a button I cant seem to get it to
    stop moving once it reaches a certain _x position it just keeps on
    moving off the stage.
    Below is the script I have so far not including any
    conditions to check if "content1" has reached it _x position
    Could anyone help please!!!!
    //on Right movie clip containing the button
    onClipEvent (enterFrame) {
    _root.content1._x += speedX;
    _root.content1._y -= speedY;
    //on Right button inside movie clip
    on (press) {
    speedX = 5.5;
    speedY = 1.33;
    //on Left movie clip containing the button
    onClipEvent (enterFrame) {
    _root.content1._x += speedX;
    _root.content1._y -= speedY;
    //on Left button inside movie clip
    on (press) {
    speedX = 5.5;
    speedY = 1.33;

    Many thanks ClBeech!!!
    I've tried the code you suggested but it doesn't seem to work
    :0(
    I'm working on a Mac using Flash Pro 8 which only has the
    option to publish as 'actionscript 1.0 or 2.0' is the script you
    supplied an actionscript 3.0?
    Below is the script with the amendments, I've changed my
    button instance names to match the script you supplied (left_btn /
    right_btn)
    stop();
    import mx.transitions.Tween;
    import mx.transitions.easing.Strong;
    var rposX = 369;
    //the ending x of the right position
    var rposY = 84;
    //the ending y of the right position
    var lposX = 116;
    //the ending x of the left position
    var lposY = 154;
    //the ending y of the left position
    right_btn.onPress = function() {
    new Tween(content1, '_x', Strong.easeOut, content1._x,
    rposX, time, false);
    new Tween(content1, '_y', Strong.easeOut, content1._y,
    rposY, time, false);
    left_btn.onPress = function() {
    new Tween(content1, '_x', Strong.easeOut, content1._x,
    lposX, time, false);
    new Tween(content1, '_y', Strong.easeOut, content1._y,
    lposY, time, false);

  • I feel Dumb - How to stop a movie clip

    Hello folks..never posted here before, so, please be gentle..
    I have used Flash CS3 for a while, and just upgraded to
    CS4...This is where i am either missing something, or just not
    looking in the right place..
    I have a basic stage...4 graphics in the clip ( converted to
    graphic symbols ), each on their own layer..Each layer is using a
    motion tween.
    What i would like to find out how to do is that when the clip
    gets to the end, to just stop. At the moment, when i upload the
    .SWF file to a webpage, its running in a loop, continuous....I used
    to do this in CS3 by adding a " stop() " command on the last
    keyframe....How do i now get the movie to stop in CS4?? I am at a
    lost, even after trawling the internet for hours today...
    Hope someone can help..
    Niko

    Outstanding....( i was sure i tried this earlier
    on...obviously not )
    Thank you so much for the prompt reply Colin...very much
    appreciated...
    Niko

  • How can I load an external SWF into a movie clip that's inside other movie clip?

    Hi.
    I creating my first flash (actionscript 3.0) website but I'm
    stuck with a visual effect I want to create.
    I have a window on my website called contentWindow. Every
    time you click a button this window is supposed to leave the stage,
    load the requested content and return to the stage.
    The sliding window is a movie clip with 83 frames, 21 to
    enter the stage, 21 to leave the stage again, 20 for nothing (its
    just to simulate the loading time) and 21 to return to the stage.
    Now my goal is, when the user clicks on a navigation button,
    the window exits the stage, loads an external SWF with the content,
    and then returns to the stage.
    I've the "window" movie clip with an instance name of
    "contentWindow". Inside there is another movie clip with an
    instance name of "contentLoader". The content that the user
    requested should appear inside the "contentLoader".
    Now, when the contentWindow leaves the stage, I get this
    error message:
    quote:
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at rwd_fla::MainTimeline/trigger()
    If I switch
    "contentWindow.contentLoader.addChild(navLoader);" for
    "contentWindow.addChild(navLoader);" it works fine, but the
    external SWF doesn't move with the window.
    How can I load an external SWF into a movie clip that's
    inside other movie clip?

    Hi,
    Recently, I have been putting together a flash presentation.
    And I am just wondering if the following might help you, in your
    communication with the said swf file:
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    onComplete);
    function onComplete(event:Event):void
    event.target.content.thinggy_mc.y -= 100;
    Not the best example, but this allows you to target a mc
    within an external swf file. I think if you look up this code, you
    will have an answer ;)
    Kind Regards,
    Boxing Boom

  • How can I convert my animation into a working movie clip that can be used with a new scene?

    Hello all,
    First and foremost, I AM A TOTAL FLASH NOOB. I want to preface this and make it incredibly clear how new this all is to me. I LITERALLY started using flash this morning; that is precisely how new I am.
    With that being said I am going to do my best to explain what I'd like to do.
    I have created an animation of a spider moving its legs back and forth. I want to be able to combine all of the layers into 1 simple animation that can be imported into new flash scenes with the animation exactly how it stands. I have figured out how to convert the whole animation into a symbol AND I have figured out how to import the movie clip from the library. However, herein lies my problem. When I open a new flash scene and import my animation, I play it and it does nothing at all. It's just the static image of the spider I created with no movement.
    I've spent the last couple hours trying to figure out (and doing my own research) what I have done or didn't do to get to this point. I'd be willing to bet I am just going about the entire process incorrectly and I'm simple overlooking a basic facet of the program.
    Any insight to fix my ignorance is greatly appreciated.
    (P.S. Hell, I don't even know if I am using the correct terminology so for all I know I am confusing every person who has taken the time to look at my question. If I am using incorrect terminology please correct me to avoid future hang ups. Thank you.)

    Ned! This totally worked! Thank you! I knew there was a tiny piece of this whole thing that was preventing me from making everything work. Unfortunately as my luck would have it, although I have the movieclip working the spritesheet converter I'm using now no longer recognizes the movie clip. The converter says there are 7 frames in the animation, but doesn't display any working sprites. Just a blank sheet. Frustrating to say the least.
    I'm just going to throw everything out on the table here:
    This is the video tutorial i'm using to convert my animation into a spritesheet. I've done the steps exactly as directly up until the point I actually click "Begin Conversion." When begin conversion is selected, it shows the movieclip exists on the bottom left underneath "list of movieclips" but doesn't actually show any individual sprites.
    Here's the simple sprite converter I am using.
    The irony of this whole situation is that you have successfully helped me make a working movieclip (which was the important piece), but the converter no longer recognizes it. Whereas before, it would at least show the image on the 1 frame of animation it had.
    If you wanted to to take a stab at it and see if you can successfully get it to work I'd be appreciative. If not, I totally understand as you have already been incredibly helpful and have my eternal gratitude for getting me this far. These animation programs can be quite overwhelming when they so vastly differ from one another. Don't even get me started no Anime' Studio Pro.

  • How to build a custom movie clip that will be used as a cell renderer for column in a grid ?

    i want to build a datagrid that shows a picture and underneath it a name.
    the problem is i dont want to see all of the pictures, but all the pictures that have certain requirements, so i cant just make one movie clip that includes all the pictures and names.
    so my question is how do i build a movie clip that contains photo and text?.

    You do not create movieclips on the timeline using code, though you can create them and add them as children of something that has been manually placed in the timeline.
    To create a MovieClip using code you use: 
        var mc:MovieClip = new MovieClip();
    If you need to add an image, then however you intend to acquire the image, after it has been acquired, you add it to the MovieClip using:  
        mc.addChild(img); 
    where img is the instance of whatever form of object the image takes (Bitmap, Loader)
    If you need to add a TextField to the MovieClip then you use: 
        var tf:TextField = new TextField();
        mc.addChild(tf);
    and you can set up properties for the textfield such as the font and color and position as well after it has been instantiated (the first line).

  • I have 3 consecutive movie clips that I am trying to drop into the drop zone but it only recognizes the first one and only produces the firts one in a DVD. How can I drop all three  movie clips into one drop zone

    On IDVD, I have 3 consecutive movie clips that I am trying to drop into the drop zone to create a DVD but it only recognizes the first one I dropped and only produced the first one in a DVD. How can I drop all three  movie clips into one drop zone.

    I have had some luck doing the following: Export each clip from imovie as a quicktime clip. Open iDVD and create a new project. Import a few stills into iDVD and then click on the button that gets created to get into the screen where the individual slides appear. Drag each quicktime into that screen and arrange in the order you want. You can then delete the stills. The button that appeared when you dropped in the stills will launch a complete show.

  • How do I stop a movie clip from looping

    I am using Action Script 3 and the 'stop()' function is not working to stop my movie clips from looping continuously.
    I have added the 'stop()' function to the last frame on the timeline of each movie clip.
    I originally built the .fla file in Flash CS6 using Action Script 2 where it was working with no problems (I have since upgraded and don't have access to CS6 anymore).
    I have all the separate movie clips positioned on Frame 1 of my main stage with the following script to start them playing:
    Cigarette_Reveal.play();
    KickTheHabit.play();
    BallMove.play();
    BallFlip.play();
    Offer.play();
    I want each of these movie clips to stop playing after one animation sequence is complete.
    Please help!

    Turn on strict mode in your publish settings. This will allow you to see the compiler errors that are preventing the actionscript in your fla from compiling correctly.

  • Dreamweaver CS4 How to play a movie clip by clicking an image

    Hi
    Can anyone recommend a DW Behaviour, Widget or simple piece of Javascript coding that would allow me to start (or start and stop) a movie clip by clicking an image.
    I have a web page created in DW CS4 which has 4 FLV video clips and I would like visitors to be able to start their clip of choice by clicking a small still from each movie stacked at the right side of the page.
    I've seen this done on many sites but don't know how complex it would be.
    Any help / advice much appreciated.
    Thanks
    George

    Hi Ned, thanks for the response;
    1.Yes I named the instance.
    2.I  don't beleive so. I started from the library creating a new symbol, added the graphics, added the key frames, then created the tween. Then I dragged the symbol onto the main stage and named the instance. So I don't think there is a movie clip inside an mc.
    Here is the main timline:
    Here is the mc timeline:
    Here is what I'm trying to do:
    stop();
    blk1._visible = false;
    blk2._visible = false;
    blk3._visible = false;
    ppk1._visible = false;
    ppk2._visible = false;
    ppk3._visible = false;
    storeCartons = new Array();
    storeCartons = [blk1, blk2, blk3, ppk1, ppk2, ppk3];
    startButton.onRelease = function() {
        myNumber = Math.floor(Math.random()*storeCartons.length);
        trace("myNumber "+myNumber);
        activeCarton = storeCartons[myNumber];
        activeCarton._visible = true;
              activeCarton.play();

  • Trying to create a movie clip that Bounces off four sides of the stage

    using the syntax below I have created a movie clip called 'BALL' that bounces off from the left "x"  and moves to the right side of the stage 'x.520' and bounces back to the start "x".
    HOW DO I CREATE A MOVIE CLIP THAT BOUNCES FOUR SIDES OF THE STAGE AND STOPS ON THE FOURTH BOUNCE??
    var ballTween:Tween = new Tween(ball, "x", Bounce.easeInOut, ball.x,520, 5, true);
    ballTween.addEventListener(TweenEvent.MOTION_FINISH,tweenFinishedF);
    function tweenFinishedF(e:TweenEvent):void{
    new Tween(ball,"x",Bounce.easeOut,ball.x,0,5,true);

    Here is a simplest way to do that. This code doesn't use your ball but draws it dynamically. If you want to use your ball instance - replace relevant lines.
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Rectangle;
    var ball:Shape;
    // speed, naturally
    var speed:Number = 7;
    // velocity along x
    var vx:Number = speed;
    // vlocity along y
    var vy:Number = speed;
    // area within which ball may move
    var moveArea:Rectangle;
    // radius of ball circle shape
    var ballRadius:Number = 20;
    init();
    function init():void
        moveArea = new Rectangle(ballRadius, ballRadius, stage.stageWidth - ballRadius, stage.stageHeight - ballRadius);
        drawBall();
        addEventListener(Event.ENTER_FRAME, moveBall);
    function moveBall(e:Event):void
        // change direction if ball moves out of allowed rectangle
        if (ball.x < moveArea.x)
            vx = speed;
        else if (ball.x > moveArea.width)
            vx = -speed;
        if (ball.y < moveArea.y)
            vy = speed;
        else if (ball.y > moveArea.height)
            vy = -speed;
        ball.x += vx;
        ball.y += vy;
    function drawBall():void
        ball = new Shape();
        ball.graphics.beginFill(0xFF0000);
        ball.graphics.drawCircle(0, 0, ballRadius);
        ball.x = moveArea.x + Math.random() * moveArea.width;
        ball.y = moveArea.y + Math.random() * moveArea.height;
        addChild(ball);
    Message was edited by: Andrei1

  • How to Remove a Movie Clip

    Hi,
    On the main timeline, I have the following code:
    external_btn.addEventListener(MouseEvent.CLICK, showMenu);
    function showMenu(e:MouseEvent):void
    var myMovieClip:MovieClip = new Member();
    addChild(myMovieClip);
    myMovieClip.x = 597.95;
    myMovieClip.y =359.15;
    in the internal movie clip, that I linked it to Member:
    In the member movie clip, I have the following code to remove the movie clip that was created in the main timeline of the root movie clip.
    release1_btn.addEventListener(MouseEvent.CLICK, goBack1);
    function goBack1(e:MouseEvent):void
    MovieClip(root).removeChild(myMovieClip);
    I received the following compiler error:
    1120: Access of undefined property myMovieClip.
    Please help me know how to resolve this error message.
    Thanks,
    Robert.

    that's (coding on more than one timeline) not good coding style, but this will correct your error and the prevent a few more:
    release1_btn.addEventListener(MouseEvent.CLICK, goBack1);
    function goBack1(e:MouseEvent):void
    MovieClip(this.parent).removeChild(this);

  • How to unload a movie clip within a movie clip.

    Hi all,
    I am trying to unload a movie clip that is on a layer in a
    movie clip. After clicking on a button, I would like the movie to
    go back to the previous menu without playing a couple of movie
    clips that's in the main movie clip.
    So at the end of my movie clip I have:
    _parent.gotoAndPlay("resources"); // resources is the frame
    name in the main movie clip where I would like the movie to restart
    from
    _parent.vhost_mc.unloadMovie("vhost_mc"); //vhost_mc is a
    movie clip in the main movie clip that I want to unload
    _parent.videoScreen_mc.unloadMovie();
    But the videoScreen_mc doesn't unload. The main movie clip
    starts with the videoScreen and I've actually deleted the frames of
    videoScreen_mc where the "resources" frame starts, but still it
    appears.
    I've even tried _parent.videoScreen_mc._visible = false; but
    nothing works! I've tried createEmptyMovieClip, but since the
    videoScreen_mc is on the main timeline, I don't think it works.
    I've even tried putting this function on the "resources" frame:
    onEnterFrame = function() {
    play();
    vhost_mc.unloadMovie("vhost_mc");
    vhost_mc.removeMovieClip();
    this.videoScreen_mc.unloadMovie();
    this.videoScreen_mc.removeMovieClip();
    this.mask._visible = false;
    But when I do this, the play button loops starting at the
    "resources" frame.
    Essentially I would like the main movie clip to play without
    certain movie clips that's included within the main movie clip.
    I hope I'm making sense. Please help, I've been at this for
    days!

    Olá Felipe, tudo bem com você?
    In order to unload content loaded into a Loader object you can use either the unload() method or the unloadAndStop() method. The difference between them is that unloadAndStop() will unload the loaded SWF and try to stop executing any code that it was running including animations, sound and event listeners.
    If you wanto to call the unload() or unloadAndStop() methods from the loaded SWF you can use its loaderInfo.loader property to reference the Loader object that loaded it.
    It could be someting like this:
    this.closeButton.addEventListener(MouseEvent.CLICK, this.handleClose);
    protected function handleClose(event:MoueEvent):void {
         this.loaderInfo.loader.unloadAndStop();
    You can pass a Boolean parameter to unloadAndStop() to indicate if Flash's garbage collector should be run ont the unloaded SWF in order to free up memory. Considering the size of your SWFs, this could be a good option. The downside is that there is a performance penalty and in my professional experience, CPU is still a resource that is more scarce than memory, so use with care.
    Hope this helps.
    Abraço,
    Rui

  • RemoveChild for movie clip that was added in another function?

    Hello everyone.  I have 3 different functions for my preloader.  I have an Event.OPEN, ProgressEvent.PROGRESS, and an Event.COMPLETE.  In the event.OPEN function, I create a new variable that is data typed to the class name of my preloader that I set in it's property dialogue box.  This is just a simple circle animation.  Below is my code for it:
    function addPreloader(event:Event):void
        var myPreloader:mcPreloader = new mcPreloader();
        myPreloader.x = stage.stageWidth / 2;
        myPreloader.y = stage.stageHeight / 2;
        myPreloader.width = 75;
        myPreloader.height = 75;
        addChild(myPreloader);
    My ProgressEvent.PROGRESS function looks like so:
    function preloadImages(event:ProgressEvent):void
        var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
        percent_txt.text = percent + "%";
    and my Event.COMPLETE function looks like so:
    function imageLoaded(event:Event):void
        var myLoadedImage:Loader = Loader(event.target.loader);
        addChild(myLoadedImage);
        new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
        event.target.loader.removeEventListener(Event.OPEN, addPreloader);
        event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
        event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
    The only problem is that when it's done loading, I'd like to remove the myPreloader from the stage.  Since it is declared in the Event.OPEN function, I can't communicate with it via my Event.COMPLETE function.  How can I successfully remove it from the stage after it's done loading?  Thanks!
    Jesse

    Duh, thanks Kglad.  It's been a long week ;).
    Jesse
    Date: Thu, 9 Jun 2011 13:47:57 -0600
    From: [email protected]
    To: [email protected]
    Subject: removeChild for movie clip that was added in another function?
    var myPreloader:mcPreloader
    function addPreloader(event:Event):void
       myPreloader = new mcPreloader();
        myPreloader.x = stage.stageWidth / 2;
        myPreloader.y = stage.stageHeight / 2;
        myPreloader.width = 75;
        myPreloader.height = 75;
        addChild(myPreloader);
    My ProgressEvent.PROGRESS function looks like so:
    function preloadImages(event:ProgressEvent):void
        var percent:Number = Math.round(event.bytesLoaded / event.bytesTotal * 100);
        percent_txt.text = percent + "%";
    and my Event.COMPLETE function looks like so:
    function imageLoaded(event:Event):void
    removeChild(myPreloader);
    myPreloader=null;
        var myLoadedImage:Loader = Loader(event.target.loader);
        addChild(myLoadedImage);
        new Tween(myLoadedImage, "alpha", Strong.easeIn, 0, 1, 0.5, true);
        event.target.loader.removeEventListener(Event.OPEN, addPreloader);
        event.target.loader.removeEventListener(ProgressEvent.PROGRESS, preloadImages);
        event.target.loader.removeEventListener(Event.COMPLETE, imageLoaded);
    >

  • IMovie How do you join video clips that have been split

    In Imovie project, How do I join video clips that been split

    Hi
    And if the clips are not contiguous - Then You have to do as in all versions of iMovie from the very beginning.
    • Put the clips into one new project
    • Export this as full quality QuickTime movie
    • Import this new merged QT-clip into Your main project
    This is a way around that are very basic and used whenever more elaborated scenes are prepared - e.g. multiple text clips or when in need of adding several functions into it.
    Tedious - but it always been like this - in contrast to FinalCut.
    Yours Bengt W

  • IMovie HD refuses to import .MOV clips that it used to import.

    I've got an odd problem. Doing a search didn't turn up anything relevant to my situation so I'm gonna try to pick some brains on here.
    My Problem: My version of iMovie(5.0.2) no longer recognizes .mov clips that it used to. Meaning that when I try to import clips using settings that worked previously, I am now confronted with an Error during import message that reads "The file could not be imported: Unknown Error". Two things have changed since I last made a project.
    1.) I have added a microphone that now allows me to record stereo audio. I don't think this is the culprit.
    2.) I updated to 10.6.6 Recently. I think this may be what messed things up.
    After trying to Drag and also import clips through the menu with no success, I tried to import clips that I have used before under the exact same conditions and was greeted with the same error. This is importing using the HDV 720p setting. If I try to import new or old clips using the standard DV (16:9) setting then everything works.
    These same clips are able to be imported into iMovie '09 with no trouble but I am uncomfortable with that interface. Is there anything I can do to continue to work in iMovie HD or would I just be better off with getting used to iMovie 09?
    Thank you for any replies.

    I have Mac 10.6.6 and use iMovie 05 transferring it to iDVD 08. It is getting less easy to do, but usually i make the movie in 05, complete with chapter marking and press the export to DVD.
    The file for the Movie I have made is saved automatically in the Movie folder on my owner/home page. To get it out to iDVD 08 open 08 and select create new project and click save This puts a small file into Documents, However to get your work into the new DVD select import>video and when the screen opens for you to find it go to your movie folder in your owners area and click to open the file. It works, but there is usually a problem somewhere along the line. Usually a different one each time, occasionally it goes like clockwork. It won't work if you try the drop down 'open' option.
    This last time I got so irritated that I've downloaded the last set of film clips to 05 and then transferred them to 08 to compare the results. I still feel that the later versions are less good (?dumbed down) and await to be converted.

Maybe you are looking for