Unload a movie

Hi all i am new to Flash so please forgive me if i sound like an idiot.
I have two buttons, once a button is clicked it loads in an external swf, the problem is that it then has to be unclicked before the second button is clicked as it otherwise runs the two movies.
Is there a way that if the second button is clicked whilst the first movie is playing it can unload the first movie before playing the second, or if no movie is playing it just plays the movie.
Thanks
Stan

Hi I am using AS3
button_3.addEventListner(MouseEvent.CLICK,fl_ClickToLoadUnloadSWF_3);
var fl_Loader_3:loader;
var fl_ToLoad_3:Boolean=true;
function fl_ClickToLoadUnloadSWF_3(event:mouseEvent):void
if(fl_ToLoad_3)
fl_Loader_3 = new Loader();
fl_loader_3.load(new URLRequest("new_products.swf"));
addChild(fl_Loader_3);
else
fl_Loader_3.unload();
removeChild(fl_Loader_3);
fl_loader_3+null;
fl_TOLoad_3 =!fl_ToLoad_3;
This is the first half of the code for one button, the code for the second button is the same, just different variable names.
thanks

Similar Messages

  • Unload parent movie after onloadInit of child movie

    Hi,
    I am loading external swf's into a main load.swf, using a Moviecliploader object. What I basically want to do is that, after an external movie, say home.swf, loads another external swf, say about.swf, home.swf should be unloaded.
    home.swf is loading about.swf into the _root.mc_holder, which is placed inside load.swf. I want all external files to be placed within this holder. Now this is working with some files, but not with others. My standard code within all files is this:
    //code within home.swf to load about.swf
    var loader:MovieClipLoader = new MovieClipLoader();
    var ldrlistener = new Object();
    loader.addListener(ldrlistener);
    ldrlistener.onLoadStart = function(_mc:MovieClip) {
        trace("about loading started");
    ldrlistener.onLoadProgress = function(_mc:MovieClip, loaded:Number, total:Number) {
        var prcnt:Number = Math.floor((loaded/total)*100);
        if (prcnt == 10) {
            trace("loading:10");
            ldgraphic.gotoAndStop("ten");
        if (prcnt == 15) {
            trace("loading:15");
            ldgraphic.gotoAndStop("fifteen");
        if (prcnt == 20) {
            trace("loading:20");
            ldgraphic.gotoAndStop("twenty");
        if (prcnt == 25) {
            trace("loading:25");
            ldgraphic.gotoAndStop("twentyfive");
        if (prcnt == 30) {
            trace("loading:30");
            ldgraphic.gotoAndStop("thirty");
        if (prcnt == 40) {
            trace("loading:40");
            ldgraphic.gotoAndStop("forty");
        if (prcnt == 50) {
            trace("loading:50");
            ldgraphic.gotoAndStop("fifty");
        if (prcnt == 55) {
            trace("loading:55");
            ldgraphic.gotoAndStop("fiftyfive");
        if (prcnt == 60) {
            trace("loading:60");
            ldgraphic.gotoAndStop("sixty");
        if (prcnt == 70) {
            trace("loading:70");
            ldgraphic.gotoAndStop("seventy");
        if (prcnt == 80) {
            trace("loading:80");
            ldgraphic.gotoAndStop("eighty");
        if (prcnt == 100) {
            trace("loading:100");
            ldgraphic.gotoAndStop("hundred");
    ldrlistener.onLoadInit = function(_mc:MovieClip) {
        ldgraphic._alpha = 0;
        trace("load completed");
    loader.loadClip("about.swf",_root.mc_holder);
    this.unloadMovie();                    //unloads home.swf, which was loaded from load.swf
    Now the problem is, it is successfully unloading the movie, but after a while it stops doing this. Is there something wrong with the code?? Any help will be greatly appreciated.

    Hi Kglad,
    I seem to have managed to get it to work so far. But once again, I can't be sure as it seems to stop working on its own. Also, if I do not insert the this.unloadMovie, the next movie does not load in some cases. I think I need to reconsider my strategy, but for now this will have to do. Thanks for the response

  • 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

  • Unloading SWF movie

    Hi,
    I've been working on a CD-Rom presentation with Flash and so
    far I was mostly using AS1 and AS2 to built it. I started to learn
    some AS3 for a part of the presentation but now I'm running into
    issue, here's the main one:
    I'm loading different SWF movie one on top of the other, and
    unloading them as needed, now this is very easy with AS1 (loadmovie
    and unloadmovie function are simple to use), but when I'm loading
    my file built with AS3 I can't figure out how to unload it. The AS3
    movie is loaded on the Level 5, I just want to make sure that when
    I'm unloading the file it's not unloading everything else.
    Can anyone help me.
    Yann Poirier

    Disregard, I found my answer

  • Unloading multiple movies at once

    I'm trying to remove multiple dynamically created movies at
    one time. I'd like all of these clips to unload when entering a new
    frame in the timeline, but the only way i know how to do this is to
    list them all individually. Is there a way to do this at once like
    a wildcard or something?
    Any help would be greatly appreciated.

    yeah or if they're all loaded into a parent clip, use the
    clips access operator to loop through and ace them, like ...

  • Load \ unload external movie

    Hi!
    While a parent movie plays, I want to replace a movie with
    others.
    The movie to be replaced was attached with the following
    instruction (attachMovie):
    _root.attachMovie("ButtonsTest", "buttonsTest_mc", 6,
    {_x:400, _y:300});
    I am looking for a way to unload the above movie and load at
    the same coordinates the new external movie.
    Please help
    TIA
    Nanu

    use loadMovie into another MC ....
    u have a MC with 2 frames ... control
    1st frame - an empty mc, clip1
    stop();
    clip1.loadMovie("the_clip1.swf")
    2nd frame - same empty, clip2
    stop();
    clip2.loadMovie("the_clip2.swf")
    the button
    on(release) {
    control.gotoAndStop(2);
    }

  • Unload a movie but gotframe or reverse frames

    Ok, I have a base movie with a background that holds the
    buttons/nav and main logos. I had loaded a content movie in there
    with a stop at the last frame. What I want to do now when I click a
    nav button, say '3D graphics page' the 3D graphics page loads the
    3D graphics movie (know how to do that) and the content page
    unloads gracefully, say playing the frames backwards to where the
    page started and unloads as the pages all come in nicely. Maybe
    just to go to another frame for a mini animation to ease out of the
    page to transition to the loading movie.
    All the nav buttons would need to be able to call the
    diffrent movies up whilst the previous movie unloads gracefully so
    I guess actionscript on the buttons wouldnt work?
    Maybe the onUnload command? Never used it.
    Can I acheive this?
    Thanks

    The only thing that comes to mind is to use some modulus math to determine when you are in a frame that should be a stopping point. This would work as long as you have spacing such as you explained...25, 50, 75....  If the currentFrame%25 == 0, then that is a frame to stop in.  As far as the act of keeping things moving, you want to employ an ENTER_FRAME event listener so that it continually processes the prevFrame() call.  As soon as you hit a stopping frame you want to remove that listener.
    If the modulus approach wouldn't cut it for all cases, then you could also try to work out some form variable implementation that is assigned the last stopping frame number as you move forward beyond it, using that variable to check against the currentFrame value in the ENTER_FRAME event handler function.

  • I have a Mac Mini, and it won't accept connecting my Sony video camera.  So I got a SD mem card reader to unload my movies from.  It worked the first time I used it a few months ago.  This time it says it doesn't recognize the format I am trying to use?

    I have all thenecessary updates.  I have switched over from a PC to Mac back in April and have nad nothing but problems adapting.  I don't know why this worked the first time, and put my videos inti imovie, and now it doesn't recognize it at all.  And the Mem card reader does work, because I just put the SD card from my regular camera into it and it downloaded those fine, it just won't take my movies!

    Which sony camera? I have a Sony HDR-CX550 right now and have been able to use the SD card as well as connect the camera directly. I also had CX110 that work too. You may want to try to copy the complete top level folder from the SD card to the Hard drive, then try to "import from Camera archive" and select that folder.

  • Unloading a movie clip from a for statement

    Hi,
    I have this code:
    //create empty movie clips to place bin top, flame and bin
    bottom in that order
    this.createEmptyMovieClip("holder_mc2",this.getNextHighestDepth());
    this.createEmptyMovieClip("holder_mc",this.getNextHighestDepth());
    this.createEmptyMovieClip("holder_mc1",this.getNextHighestDepth());
    //attach movie clip/variables
    var dsfInstance:DropShadowFilter = new DropShadowFilter(5,
    45, 0x000000, 1, 10, 10);
    var b:MovieClip =
    holder_mc2.attachMovie("binTop_mc","binTop_mc",holder_mc2.getNextHighestDepth());
    var a:MovieClip =
    holder_mc1.attachMovie("binBottom_mc","binBottom_mc",holder_mc1.getNextHighestDepth());
    //property values
    a._x = 419;
    a._y = 244;
    a._width = 112.0
    a._height = 140.0
    b._x = 419;
    b._y = 175;
    b._width = 112.8;
    b._height = 10.1;
    a.filters = [dsfInstance];
    //create for loop to place the flame particle on the stage
    many times
    for(i=0;i<200;i++){
    //places in temporary movieclip t
    var t:MovieClip =
    holder_mc.attachMovie("flame","flame"+i,holder_mc.getNextHighestDepth());
    // position the movieclip on the stage for y co-ordinates
    t._y = 190;
    t._x = Math.random()*80+(Stage.width/2+115);
    //give the flame random sizes no larger than 80 pixels and no
    smaller than 20
    t._xscale = t._yscale = Math.random()*80 + 20;
    //randomize the frame the movieclip is going to start in the
    flame movie clip is 16 frame long so it will pick number between
    that
    //because math.random produces decimal values we round the
    number using math.ceil to the high whole number
    t.gotoAndPlay(Math.ceil(Math.random()*16));
    what i want to do is remove the movieclip in the for loop off
    the stage when i click on a button. i can manage to remove the
    movie clips with the variables a and b but i cant do it with the
    one in the for loop.
    i put this code in the button:
    on(release){
    play();
    stopAllSounds();
    a.removeMovieClip();
    b.removeMovieClip();
    t.removeMovieClip();
    Is there a way to do this?

    im so dumb! i figured it out.
    i used the "holder_mc" the name of the empty movie clip.
    holder_mc.removeMovieClip();

  • Unload FLV movies when clicking home

    Is there a way to set up an unload FLV actionscript (AS3) on
    the click of a home button? So, when defining the functions of the
    home_btn, have it unload FLV (sound and video).
    Or would it be better to put into the actionscript frame? So,
    when the home_btn brings the timeline to "home", the actions on
    that keyframe have an unload FLV.
    Help would be greatly appreciated

    Did you ever find a solution for this?  I'm having the same trouble; I have multiple FLVs linked in welcome.swf, but when I load a different .swf file the sound continues.  I need to unload the FLVs (or at least stop the sound), but I don't know 1) what that script is and 2) where to put that script.
    Any help would be appreciated!

  • Hello please, somebody knows how to unload a movie clip recently loaded and back to the main SWF?

    Good night guys!
    I come humbly ask for your help ...
    I have an extensive animation .. A kind of map of Brazil with 33 stores in 4 states distributed .. Clicking on the desired state, it expands and appear their stores. Only the animation and the first store were enough to generate a SWF comporting 3 megabytes .. So I decided to use an external SWF to every single stores, otherwise would be too heavy ..
    My goal is: Every shop clicked, loads a new external SWF which occupies the entire screen .. So if I wanted to return to the main SWF with button, how should I proceed?
    I have found an article that shows communication between two SWF, however, some steps did not work and I want it to button.
    Please, if you know, needs to be in ActionScript 3.
    Can somebody help me?
    Thanks, I hope to answer

    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

  • Unloading a flash movie using Safari browser

    I have MAC 10.4 and safari 2.0 browser.I run a flash movie(Instruction.swf) and after that the actual test for the student run.So while running The first movie i.e Instruction.swf I am not able to unload that movie using javascript in Safari 2.0 browser so that the actual test can run.It just hang up after finishing the movie.While in the other Mac and windows it is working fine.
    Please Help me.
    Thanks In Advance.

    Welcome to Apple Discussions!
    Do you mean to say, in other Mac and Windows web browsers it is working fine? If that's the case, it sounds like the version of Flash plugin used by the Safari plugin is probably older than the one used by the other web browsers.
    With Safari Enhancer's enabling of the Debug menu you can force certain webpages to open in other web browsers. That would help streamline your viewing of those pages.
    http://www.lordofthecows.com/safari_enhancer.php
    You can also enable the Debug menu with:
    defaults write com.apple.Safari IncludeDebugMenu 1
    from the Terminal.

  • Load & Unload Movie Issue

    Hi Guys:
    Have 2 unable solve issues, would be much appreciated if anyone could help.
    // ISSUE 1 //
    I am experiencing an issue with Load & Unload Movie.  What happen is that I am trying to load an external SWF into a movie clip call movieContainer in my main website.  This external SWF file has timeline that perform a animation when it's loaded into the movieContainer.
    I can load and unload the movie with no problem...the issue is that after I unload the SWF and then at any point of the movie on the main website I click to load the SWF back to the stage.....the timeframe of the SWF file stay at where it get left off(when it's unloaded).  I am trying to make it play start all over again.
    I try the movieContainer.content.gotoAndPlay(1); but it doesn't do anything. Any idea how I could make this work?
    Here is my code:
    var content:Loader = new Loader();
    content.load(new URLRequest("externalSwf/content.swf"));
    loadMovieButton.addEventListener(MouseEvent.CLICK, loadMovieButtonClicked);
    function loadMovieButtonClicked(e:MouseEvent):void{
        movieContainer.addChild(content);
    // ISSUE 2 //
    In my external SWF file, I have create a loading loader at the 1st frame.  But it doesn't play all the time when I testing on the server.  It works just fine when I test locally with TEST MOVIE.  Not only it doesn't play all the time.....it suppose to play from 2nd frame of the movie after the loading is finished (I have a short animation play between frame 2 - frame 20)  Instead of playing from frame 2 to frame 20, the animation just jump straight to frame 20...which mean the user won't see the animation between frame 2 - frame 20.
    import flash.events.ProgressEvent;
    function update(e:ProgressEvent):void
    var percent:Number = Math.floor( (e.bytesLoaded*100)/e.bytesTotal );
    if(preloaderMC is MovieClip){
    preloaderMC.gotoAndStop(percent);
    //preload_txt.text = String(percent);
    if(percent == 100){
    gotoAndPlay(2);
    loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
    // Extra test for IE
    var percent:Number = Math.floor( (this.loaderInfo.bytesLoaded*100)/this.loaderInfo.bytesTotal );
    if(percent == 100){
    nextFrame();
    stop();
    Many Thanks!

    Thanks for the reply, the code I use to load the external SWF is:
    The button is within a movieClip: commercialScrollBar_mc
    The button instance name is: stackPancakeBar
    The external SWF get to load into a movieClip container call: projectDetailsContainer_mc
    var ldr:Loader = new Loader();
    ldr.load(new URLRequest("projectsCommercial/stackPancakeBar.swf"));
    commercialScrollBar_mc.stackPancakeBar.addEventListener(MouseEvent.CLICK, stackPancakeBarClicked);
    function stackPancakeBarClicked(e:MouseEvent):void{
        MovieClip(ldr.content).gotoAndPlay(1);
        projectDetailsContainer_mc.addChild(ldr);
    I was thinking does it has anything to do with the UNLOAD script I have on the external SWF file? Below are the code for removing the child.
    back_btn.addEventListener(MouseEvent.CLICK, removeProjectDetails);
    function removeProjectDetails(e:MouseEvent):void{
        this.parent.parent.removeChild(this.parent);
    Thanks Heaps, by the way, do you have any idea why the loading sequence doesn't get to play every time?  Or perhape the file size is too small?

  • Unloading external flash movie

    I am using this script to load a swf file into a mc:
    var imageRequest:URLRequest = new URL Request("movie.swf");
    var imageLoader:Loader = new Loader();
    imageLoader.load(imageRequest);
    addChild(imageLoader);
    This works great. Now what script do I use to unload the
    movie.swf?
    MM

    Welcome to Apple Discussions!
    Do you mean to say, in other Mac and Windows web browsers it is working fine? If that's the case, it sounds like the version of Flash plugin used by the Safari plugin is probably older than the one used by the other web browsers.
    With Safari Enhancer's enabling of the Debug menu you can force certain webpages to open in other web browsers. That would help streamline your viewing of those pages.
    http://www.lordofthecows.com/safari_enhancer.php
    You can also enable the Debug menu with:
    defaults write com.apple.Safari IncludeDebugMenu 1
    from the Terminal.

  • Moving the play head in the main timeline from a button in a movie clip

    I have a movie clip that loads and when it is done playing it has a close button that unloads the movie clip... I want to add code to this button that moves the play head to frame 20 of my main timline using actionScript 3.0

    Tried that but dose not work think its because I am loading the movie this way...
    Play button "playFinal"
    function lastQuestion(event:MouseEvent):void{
         var Info:final1 = new(final1);
         this.stage.addChild(Info);
         Info.x=511
         Info.y=340; }
    So I tried using the Name "Info"
    //example......    MovieClip(Info.root).gotoAndStop(20);
    And I tried the name of the clip in the library "final1"
    //example......    MovieClip(final1.root).gotoAndStop(20);
    Is it because im loading it with actions script instead of having it on the timeline?

Maybe you are looking for

  • How do I remove appshat when resetting firefox doesn't work???

    I have went through control panel and uninstalled anything from that day that I had installed. I also went and reset firefox. I also went and removed it from the add-ons Manager tab. I don't know what else to do really. Any help will be greatly appre

  • HUGE Customer Service Problem

    Yesterday I had two new Verizon landlines added at my home. One works fine. The other turned out to actually be someone else's telephone #. After hours on the phone with the mostunresponsive uncaring CSRs I have ever encountered, I was finally assign

  • AS10g installation hangs on SLES9

    We are trying to install AS10g (9.0.4.0.0) infrastructure. The problem is the installer hangs on: Configuration Assistants -> Directory Integration Platform Configuration Assistant Nothing happens, and the machine is COMPLETELY idle. As we can see be

  • V 2 in the UK yet anybody?

    Anybody in the UK managed to get the new V. 20 firmware yet? I have an unbranded N97, code 0585162, still showing no new updates available at 13.45 29/10/09.Mind the V. 12 FW wasn't available for several weeks after the rest of the world so I'm not h

  • Problems with exporting clips from GoPro cam

    hi! I am using PP cs3  and it works fine with DV and HDV. But I am having problems exporting vids from GoPro (spec: http://www.goprocamera.com/index.php?area=2&productid=7). When I render it everything looks fine, but when I export it seems to repeat