Unloading external swf file keeps memory usage growing up

Hello everybody,
The idea is very simple: I have a submain.swf with 5 buttons. Each button loads an external .swf file.
com_loader.load(URLRequest);
After playing first external swf, before I go to next one, I try to unload it:
1. remove all its associated listeners:
com_loader.contentLoaderInfo.removeEventListener(Event.INIT-PROGRESS-COMPLETE, idFunction);
2. unload it:
com_loader.unload();
3. set to null:
com_loader = null;
and load next external swf file and so on.
The problem is that the FireFox/IE8.0 Memory Usage in Task Manager is going up and I see no sign of GC activity even after 5 mins of playing. Can anyone light me up pls? This is the second week working around and no good news until now.
Thanks in advance.
P.S.
If I try com_loader.unloadAndStop(); it gives me the error: Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed.
Vince.

Hi Ice,
The loaded swf file contains only a small photo, just for testing, with no listeners or other stuff in it.
Vic.

Similar Messages

  • Remove / unload external swf file(s) from the main flash file and load a new swf file and garbage collection from memory.

    I can't seem to remove / unload the external swf files e.g when the carousel.swf (portfolio) is displayed and I press the about button the about content is overlapping the carousel (portfolio) . How can I remove / unload an external swf file from the main flash file and load a new swf file, while at the same time removing garbage collection from memory?
    This is the error message(s) I am receiving: "TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/removeChild()
    at index_fla::MainTimeline/Down3()"
    import nl.demonsters.debugger.MonsterDebugger;
    var d:MonsterDebugger=new MonsterDebugger(this);
    stage.scaleMode=StageScaleMode.NO_SCALE;
    stage.align=StageAlign.TOP_LEFT;
    stage.addEventListener(Event.RESIZE, resizeHandler);
    // loader is the loader for portfolio page swf
    var loader:Loader;
    var loader2:Loader;
    var loader3:Loader;
    var loader1:Loader;
    //  resize content
    function resizeHandler(event:Event):void {
        // resizes portfolio page to center
    loader.x = (stage.stageWidth - loader.width) * .5;
    loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    /*loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;*/
    addEventListener(Event.ENTER_FRAME, onEnterFrame,false, 0, true);
    function onEnterFrame(ev:Event):void {
    var requesterb:URLRequest=new URLRequest("carouselLoader.swf");
    loader = null;
    loader = new Loader();
    loader.name ="carousel1"
    //adds gallery.swf to stage at begining of movie
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requesterb);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    // stop gallery.swf from duplication over and over again on enter frame
    removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent):void {
    // re adds listener for contact.swf and about.swf
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
    var requester:URLRequest=new URLRequest("carouselLoader.swf");
        loader = null;
    loader = new Loader();
    loader.name ="carousel"
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    removeChild( getChildByName("about") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of gallery.swf
    MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    function Down1(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    var requester:URLRequest=new URLRequest("contactLoader.swf");
    loader2 = null;
    loader2 = new Loader();
    loader2.name ="contact"
    loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader2.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader2);
    loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    function Down3(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    var requester:URLRequest=new URLRequest("aboutLoader.swf");
    loader3 = null;
    loader3 = new Loader();
    loader3.name ="about"
    loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader3.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader3);
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    removeChild( getChildByName("carousel") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
    stop();

    Andrei1,
    Thank you for the helpful advice. I made the changes as you suggested but I am receiving a #1009 error message even though my site is working the way I wan it to work. I would still like to fix the errors so that my site runs and error free. This is the error I am receiving:
    "TypeError: Error #1009: Cannot access a property or method of a null object reference."
    I'm sure this is not the best method to unload loaders and I am guessing this is why I am receiving the following error message.
         loader.unload();
         loader2.unload();
         loader3.unload();
    I also tried creating a function to unload the loader but received the same error message and my portfolio swf was not showing at all.
         function killLoad():void{
         try { loader.close(); loader2.close; loader3.close;} catch (e:*) {}
         loader.unload(); loader2.unload(); loader3.unload();
    I have a question regarding suggestion you made to set Mouse Event to "null". What does this do setting the MouseEvent do exactly?  Also, since I've set the MouseEvent to null do I also have to set the loader to null? e.g.
    ---- Here is my updated code ----
    // variable for external loaders
    var loader:Loader;
    var loader1:Loader;
    var loader2:Loader;
    var loader3:Loader;
    // makes borders resize with browser size
    function resizeHandler(event:Event):void {
    // resizes portfolio page to center
         loader.x = (stage.stageWidth - loader.width) * .5;
         loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
    //adds gallery.swf to stage at begining of moviie
         Down();
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent = null):void {
    // re adds listener for contact.swf and about.swf
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
         var requester:URLRequest=new URLRequest("carouselLoader.swf");
         loader = new Loader();
         loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader.load(requester);
         } catch (error:SecurityError) {
         trace(error);
         this.addChild(loader);
         loader.x = (stage.stageWidth - 739) * .5;
         loader.y = (stage.stageHeight - 500) * .5;
    // sure this is not the best way to do this - but it is unload external swfs
         loader.unload();
         loader2.unload();
         loader3.unload();
    // remove eventlistner and prevents duplication of gallery.swf
         MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         function Down1(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         var requester:URLRequest=new URLRequest("contactLoader.swf");
         loader2 = null;
         loader2 = new Loader();
         loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);    
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader2.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader2);
         loader2.x = (stage.stageWidth - 658.65) * .5;
         loader2.y = (stage.stageHeight - 551.45) * .5;
    loader.unload();
    loader2.unload();
    loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         function Down3(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         var requester:URLRequest=new URLRequest("aboutLoader.swf");
         loader3 = null;
         loader3 = new Loader();
         loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader3.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader3);
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
         loader.unload();
         loader2.unload();
         loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
         stop();

  • How to load and unload more than one external swf files in different frames?

    I do not have much experience on Adobe Flash or Action Script 3, but I know the basics.
    I am Arabic language teacher, and I design an application to teach Arabic, I just would like to learn how to load and unload more than one external swf files in different frames.
    Thanks

    Look into using the Loader class to load the swf files.  If you want to have it happen in different frames then you can put the code into the different frames.

  • How to unload the external .swf file when move on to other section?

    Hi,
    The following code provided by Mr. kglad works great in loading an external .swf file onto stage. Now, when I click on Contact (Button), the external .swf file to be removed completely. How to code on contact (Button) to work it out.
    Gallery.addEventListener(MouseEvent.CLICK, GalleryClick);
    function GalleryClick(e:Event):void{
    if(currentClip != Gallery_mc){
    currentClip.visible = false;
    Gallery_mc.visible =true;
    currentClip =Gallery_mc;}
    var loader:Loader=new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ClipLoaded);
    loader.load(new URLRequest("Gallery.swf"));
    function ClipLoaded(e:Event):void{
    Gallery_mc.addChild(loader);
    loader.x=0;
    loader.y=120;
    loader.width=1000;
    loader.height=700
    I tried the following code for Contact_btn to unload the Gallery.swf file which throws an error: 1120: Access of undefined property loader.
    Contact.addEventListener(MouseEvent.CLICK, ContactClick);
    function ContactClick(e:Event):void{
    if(currentClip != Cotnact_mc){
    currentClip.visible = false;
    Cotnact_mc.visible =true;
    currentClip = Cotnact_mc;
    Gallery_mc.removeChild(loader);}}

    like so:
    Gallery.addEventListener(MouseEvent.CLICK, GalleryClick);
    function GalleryClick(e:Event):void{
    if(currentClip != Gallery_mc){
    currentClip.visible = false;
    Gallery_mc.visible =true;
    currentClip =Gallery_mc;}
    var loader:Loader=new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ClipLoaded);
    loader.load(new URLRequest("Gallery.swf"));
    function ClipLoaded(e:Event):void{
    loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, ClipLoaded);
    Gallery_mc.addChild(loader);
    loader.x=0;
    loader.y=120;
    loader.width=1000;
    loader.height=700
    I tried the following code for Contact_btn to unload the Gallery.swf file which throws an error: 1120: Access of undefined property loader.
    Contact.addEventListener(MouseEvent.CLICK, ContactClick);
    function ContactClick(e:Event):void{
    if(currentClip != Cotnact_mc){
    currentClip.visible = false;
    Cotnact_mc.visible =true;
    currentClip = Cotnact_mc;
    if(loader){
    if(loader.stage){
    gallery_mc.removeChild(loader);
    loader.unloadAndStop();  // for fp 10+
    loader=null;  // if loader no longer needed

  • Load and unload the external swf file using AS3(for window, IOS and android)

    For the external swf file loading, I use this code
    load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene02.swf"), _lc);
    its working great but I don’t know how to unload the loaded swf files (looking: unload one by one and unload all)
    in AS2 we have
    on (release) {
              loadMovieNum("scene2.swf", 1);
              unloadMovieNum(2);
              unloadMovieNum(3);
    but i need in AS3

    Now I use this code and this time I got these compiler errors
    package {
                    import flash.display.SimpleButton;
                    import flash.display.MovieClip;
                    import flash.events.MouseEvent;
                    //import flash.display.URLRequest;
                    //import flash.display.Loader;
                    import flash.events.Event;
                    import flash.system.ApplicationDomain;
                    import flash.net.URLRequest;
                    import flash.system.LoaderContext;            
                                    public class load1 extends SimpleButton {
                                                    var loadit:Loader;              
                                                    public function load1() {
                                                                    this.addEventListener(MouseEvent.MOUSE_DOWN, loadfile);
                                                    private function loadfile(event:MouseEvent):void {
                                                                    trace("you clicked me");
                                                                    loadit = new Loader();
                                                                    this.parent.addChild(loadit);
                                                                    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                                                                    loadit.load(new URLRequest("s01.swf"), _lc);
                                                    private function unloadfile(event:MouseEvent):void {
                                                                    loadit.unloadAndStop();

  • Remove external swf file

    I have loaded an external swf file which plays a flv file by default as swf is loaded. Now the problem is how do i remove the swf file from memory. my code :
        var myLoader:Loader = new Loader();                    
        var url:URLRequest = new URLRequest("ExternalSWF.swf"); 
        myLoader.load(url);                                    
        detailMovieClip.movieHolder.addChild(myLoader);
    I have tried many combinations of removeChild, unload and unloadAndStop but none works. I figure its all about not referencing correctly.

    Hi Jah,
    i understood your problem,i faced this problem many time but couldn't find correct solution.
    I'm using now Event.REMOVED_FROM_STAGE. this method dispatch to parent swf for when the External swf removed from stage.
    The sample example code below for the way of remove externalswf events:
    parent swf actionscript code:
    import flash.events.MouseEvent;
    var myLoader:Loader = new Loader();                   
    var url:URLRequest = new URLRequest("ExternalSWF.swf");
    myLoader.load(url);                                   
    b_mc.addChild(myLoader);
    a_mc.addEventListener(MouseEvent.CLICK,onClick);
    function onClick(event:MouseEvent):void
        a_mc.removeEventListener(MouseEvent.CLICK,onClick);
        myLoader.unload();
        b_mc.removeChild(myLoader);
        myLoader=null;
    ExternalSWF.swf actionscript code:
    import flash.events.Event;
    var num:Number=0;
    addEventListener(Event.ENTER_FRAME,onRun);
    addEventListener(Event.REMOVED_FROM_STAGE,onRemoveFromParent);
    // remove all local events here//
    function onRemoveFromParent(event:Event):void
        trace("remove");
        removeEventListener(Event.ENTER_FRAME,onRun);
    function onRun(event:Event):void
        num++;
        trace(num);
    Thanks/

  • Trying to properly code a menu with buttons that can go back and forth between external swf files

    I have a project I've been working on that, when properly coded, has a "main menu" with 4 "doors" (buttons). When the corresponding buttons to these "doors" are clicked, it should go to and play an external .swf file. If that doesn't make sense, think of a DVD menu. You click play movie, it plays the movie. When the movie is over, there's two buttons on that swf file to either play the movie over or go back the main menu, which is an external .swf file (Remember, we go to the movie from the menu, which is a seperate file). So far, the buttons work. The menu works. However, from the movie, at the conclusion, when I click the button to go back to the main menu, it displays the movie clip and the buttons, but none of the buttons work. I'm starting to think it has to do with the fact the main menu was written in AS3 and the movie was made in AS2. If anyone can assist me in being to able to keep both files and still navigate between the two, being able to bring up the menu from the movie and be able to play the movie again, and so on and so on, that'd be GREAT. I'm somewhat of a noob to Flash, but I learn quickly and I'm open to any suggestions. Here's the code for main menu, which I guess acts as the parent file, and the movie. If I get this to work, I essentially would duplicate the same actions for the other 4 doors, once I complete the environments for them. Thanks
    Main.Fla/Swf (written in AS3)
    (This is the action on the first frame, that has all the buttons. For this question, I'm just trying to properly code for 'Door4', which is the "door" to the movie.)
    import flash.display.Loader;
    stop();
    var myLoader1:Loader=new Loader ();
    Door4.addEventListener(MouseEvent.CLICK, jayzSwf);
    function jayzSwf(myevent1:MouseEvent):void
              var myURL1:URLRequest = new URLRequest("jayzspeaks.swf");
              myLoader1.load(myURL1);
              addChild(myLoader1);
              myLoader1.x = 0;
              myLoader1.y = 0;
    Movie.Fla/Swf (written in AS2)
    (This is action on the button that returns to the menu)
    on (release) {
              this.createEmptyMovieClip("container",this.getNextHighestDepth());
              container.loadMovie("main.swf");

    At least you're going in the correct (mis)direction. You have AS3 loading AS2. So that's not a huge hurdle.
    I believe all you really need to do is send your Main.swf a signal that the content it loaded (e.g. jayzspeaks.swf) is done and you want to get rid of it.
    The code I pointed you to asks you to (upon download and import then) instantiate it in both AS2 and AS3. They give a very simple easy to understand line of code.
    // as2, load this in jayzspeaks.swf
    var myBridge:SWFBridgeAS2 = new SWFBridgeAS2("connectionID", clientObj);
    // as3, load this in main.swf
    var myBridge:SWFBridgeAS3 = new SWFBridgeAS3("connectionID", clientObj);
    Make sure the connectionID matches between them. Set it to whatever you want.
    When you're done with your as2 loaded content you'd send a signal (over localconnection) back to the AS3 Main like they say:
    myBridge.send("someFunctionToUnloadContent");
    myBridge.close();
    You'd need to make the as3 function "someFunctionToUnloadContent()" (example purposes only name) and it should unload the jayzspeaks.swf that was loaded in the loader.
    Make sure you get that close in there so you don't drill up a bunch of localconnection objects just like the simple source code says.

  • How to Load/Unload external SWF

    Hey all, I'm in a desperate struggle to meet a deadline for college coursework. I am unable to UNLOAD an external SWF file that I have put inside another SWF file. The problem that is occurring is, although it loads successfully, when I attempt to navigate to another page after viewing the external SWF, I expect it to close as it goes on to another page however, it remains in place. If i then go back on to the page that it is loading from, it will start to keep adding more and more SWF's. The print screens should explain it easier... Below i'll post the code that I'm using currently. The external SWF I am trying to load/unload is an interactive hangman game (whether it being interactive has an effect I do not know), but any and all help with this would be seriously appreciated!
    The code currently being used is:
    var _swfLoader:Loader;
    var _swfContent:MovieClip;
    loadSWF("Real Hangman.swf");
    function loadSWF(path:String):void {
       var _req:URLRequest = new URLRequest();
       _req.url = path;
       _swfLoader = new Loader();
       setupListeners(_swfLoader.contentLoaderInfo);
       _swfLoader.load(_req);
    function setupListeners(dispatcher:IEventDispatcher):void {
       dispatcher.addEventListener(Event.COMPLETE, addSWF);
       dispatcher.addEventListener(ProgressEvent.PROGRESS, preloadSWF);
    function preloadSWF(event:ProgressEvent):void {
       var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
       // swfPreloader.percentTF.text = _perc + "%";
    function addSWF(event:Event):void {
       event.target.removeEventListener(Event.COMPLETE, addSWF);
       event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF);
       _swfContent = event.target.content;
       _swfContent.addEventListener("close", unloadSWF);
       addChild(_swfContent);
    function unloadSWF(event:Event):void {
       _swfLoader.unloadAndStop();
    removeChild(_swfContent);
       _swfContent = null;
    This printscreen is showing what it looks like in the Flash view (plain background and external SWF loads when this SWF is published)
    What it looks like when loaded as published swf
    Picture of the external SWF working inside the other SWF
    Picture of it not being able to unload when i navigate to another page!
    Finally, a picture of it doubling up when i proceed to go on the 'game' page again, it just keeps loading the SWF's rather than unloading them!

    for example, file1 consits of two buttons, and also considered as main page. As i click on these two buttons , it will lead me go to open the external file2.swf, and file3.swf respectively. (file2.swf and file3.swf could have other navigation buttons, however, i am just simplify here).
    the code you provided is working fine. but i want to totally remove/unlink the orginal file (file1.swf) when i click on either buttons which could lead me to other page (file1.swf or file2.swf).
    Besides that, in file2.swf and file3.swf could have another "back" button to turn it back to the main page (file1.swf). When the user click on that back button, the file2.swf will unloaded...and file1.swf will be called back again...
    can it  be done?
    so sorry if my poor explanation makes you confuse..
    thank you.

  • UNLOAD External SWF on Mouseclick

    All of my buttons load their respective external swf files. However, they load on top of each other. How do I set each button to UNLOAD the external swf's that have already been loaded by the previous buttons.
    Here is what I have now:
    movieClip_1.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF); 
    var fl_Loader:Loader; 
    //This variable keeps track of whether you want to load or unload the SWF 
    var fl_ToLoad:Boolean = true; 
    fl_ClickToLoadUnloadSWF(null); // load the swf at the start
    function fl_ClickToLoadUnloadSWF(event:MouseEvent):void 
        if(fl_ToLoad) 
            fl_Loader = new Loader(); 
            fl_Loader.load(new URLRequest("album1.swf")); 
            addChild(fl_Loader); 
            fl_ToLoad = false;
        else 
            fl_Loader.unload(); 
            removeChild(fl_Loader); 
            fl_Loader = null; 
            fl_ToLoad = true;
    movieClip_2.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_2);
    var fl_Loader_2:Loader;
    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad_2:Boolean = true;
    function fl_ClickToLoadUnloadSWF_2(event:MouseEvent):void
        if(fl_ToLoad_2)
            fl_Loader_2 = new Loader();
            fl_Loader_2.load(new URLRequest("album2.swf"));
            addChild(fl_Loader_2);
        else
            fl_Loader_2.unload();
            removeChild(fl_Loader_2);
            fl_Loader_2 = null;
        // Toggle whether you want to load or unload the SWF
        fl_ToLoad_2 = !fl_ToLoad_2;
    movieClip_3.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_3);
    var fl_Loader_3:Loader;
    //This variable keeps track of whether you want to load or unload the SWF
    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("album3.swf"));
            addChild(fl_Loader_3);
        else
            fl_Loader_3.unload();
            removeChild(fl_Loader_3);
            fl_Loader_3 = null;
        // Toggle whether you want to load or unload the SWF
        fl_ToLoad_3 = !fl_ToLoad_3;

    Your code is too much bad , sorry to say.
    Please try the following code that I have made for you.
    Here the code is much too smaller than yours and also hope it will solve your problem.
    import flash.events.MouseEvent;
    import flash.display.Loader;
    movieClip_1.addEventListener(MouseEvent.CLICK, loadUnloadSWF); 
    movieClip_2.addEventListener(MouseEvent.CLICK, loadUnloadSWF);
    movieClip_3.addEventListener(MouseEvent.CLICK, loadUnloadSWF);
    var fl_ToLoad:Boolean = true; 
    var fl_Loader:Loader;
    var previous_btn:String;
    loadUnloadSWF(null);
    function loadUnloadSWF(event:MouseEvent):void
        try{
        var str:String = event.target.name.split("_")[1];
        }catch(e:Error){str="1";}
        try{
        fl_Loader.unload(); 
        }catch(e:Error){}
        if(previous_btn != str)
            fl_Loader = new Loader();
            fl_Loader.load(new URLRequest("album"+str+".swf")); 
            addChild(fl_Loader); 
        previous_btn = str;
    Regards
    Sazzad Ahmmed Mohon

  • FAQ: How do I load an external SWF file into a parent SWF file?

    A ton of Flash users visit Adobe’s we site every month wondering  about how to load an external SWF file from within another SWF.
    Adobe's own TechNote on the subject attempts to answer the basic question, along with some common follow-up questions, including:
    How do I load more than one SWF?
    How do I load a SWF into a specific location in the display list?
    How do I resize the loaded SWF?
    How do I set its X and Y location?
    Here are some additional resources that elaborate on loading content and on working with the display list:
    Sample files for the above TechNote. A set of 3 FLA and 3 corresponding SWF files, including a parent SWF and 2 SWFs that the parent loads.
    Help > AS3 Developer’s Guide > Loading an external SWF file
    Help > AS3 Developer’s Guide > Loading display content dynamically
    Loading multiple external SWFs within a main SWF – CreativeCow.net forums
    Video tutorial: ActionScript 101 – Episode 6: Adding named objects to the Stage. By Doug Winnie. An example of how to add the loaded external asset to the Stage and modify its location or other properties.
    Video tutorial: Preloading in ActionScript 3.0.  By Lee Brimelow. A slightly more complicated example, showing how to  make the parent SWF display information about the progress of loading  the external SWF.
    Tutorial: Loading and unloading SWFs - FlashAndMath.com
    This article provides several examples of how to communicate between a parent SWF file and the loaded SWF:
    SWF to SWF Communcation via ActionScript 3.0 (by kglad)

    quote:
    Originally posted by:
    NedWebs
    You now seem to want to get rid of the swf once it has loaded
    and played itself thru. To do that you would need to have something
    in the swf itself that triggers its removal in its last frame. The
    following might work...
    MovieClip(this.parent).removeChild(this);
    Unfortunately I couldn't get this to work. I placed it on the
    last frame of the SWF to be called - is that right?
    I am not sure I am doing it correctly...

  • How to load External swf file in AIR

    I try this code its working in computer but when I publish this file in .apk or .ipa , my external swf file is not opening
    (I include my external file as well)
    places_btn.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
         trace("you clicked me");
         var loadit = new Loader();
         addChild(loadit);
         loadit.load(new URLRequest("scene02.swf"));

    thx boss its working great
    I have 3 scenes; load scene code is working great
    1. How can I unload the scene?
    2. Can I unload all scenes or one by one?
    can I unload some think like this
    Load scene 2 , unload scene 1 and scene 3
    Load scene 3, unload other all scene
    i try this
    load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene02.swf"), _lc);
              loadit.unload();
    load3.addEventListener(MouseEvent.MOUSE_DOWN, newvid1);
    function newvid1(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene03.swf"), _lc);
              loadit.unload("scene01.swf scene02.swf");

  • Unload external swf from flv component

    Please help.
    Is it possible to add action script to the flv player
    componet buttons?
    I am trying to unload an external swf file (voice over) if
    the viewer chooses to play one of the many videos in the
    presentation. Currently I am using an invisible button over the flv
    component play button which unloads the swf. This works but would
    rather assign the action directly to the flv play button on press.
    Any suggestions? Thank you

    I've created a empty movieclip at x : 0, y : 0 instanced as "container"
    i've got working like this,
    but now i 'm trying to call a function in root, directly from child.
    luca.swf (back button_
    box.bt_voltar.addEventListener(MouseEvent.CLICK,onClosed);
    function onClosed(e:MouseEvent):void {
              if(this.parent) {
                         if(this.parent is Loader && this.parent.parent)
                          this.parent.parent.removeChild(this.parent);
                         else
                          this.parent.removeChild(this);
              var p:MovieClip = this.parent.parent as MovieClip;
              p.traceEntrada();
    and main.swf
    function lucaHandler(e:MouseEvent):void
                        limpaHome();
                        bt_luca.visible = false;
                        bt_conheca.visible = false;
                        bt_jogo.visible = false;
                                    var ldrLuca:Loader=new Loader();
                                  ldrLuca.load(new URLRequest("luca.swf"));
                                  ldrLuca.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
                                  addChild(ldrLuca);
                        function onCompleteHandler(loadEvent:Event):void{
                                  container.addChild(loadEvent.currentTarget.content);
    function traceEntrada():void{
                   trace("called from B.swf");
    Now, as you can see, how can i call a function in parent from the loaded swf.
    how can i call this trace function from the external loaded swf?
        var p:MovieClip = this.parent.parent as MovieClip;
         p.traceEntrada();
    ps, im not using classes

  • Unload external swf

    I loaded an external SWF file, now I need to understand how to unload the external SWF file. Is it possible to add the code to the last frame of the external SWFs internal timeline, so when it exits the last frame, it unloads itself.
    The script to load the SWF is below. Can I add the unload code to the last frame of timeline of the SWF?
    var Xpos:Number = 0;
    var Ypos:Number = 0;
    var swf:MovieClip;
    var loader:Loader=new Loader();
    var defaultSWF:URLRequest = new URLRequest("c1room.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);

    in the last frame of your loaded swf:
    if (this.parent is Loader) {
        this.parent.parent.dispatchEvent(new Event("playCompleted"));
    and on the timeline that contains yoru loader in your main loading swf:
    this.addEventListener("playCompleted",f)
    function f(e:Event){
        removeChild(ldr);  // where ldr is your loader that loads your external swf
        ldr.unload();
        ldr=null

  • How do I find the width of an external swf file that I am loading in

    I have loaded in an external swf file and it works fine.
    However, when I get the width dimensions of the movieclip that is housing the external swf file it gives me a '0' for the width.
    Thanks for your time.

    you must wait until loading is complete before trying to access the loaded objects width.  at that point you can determine the width,height of the onstage/backstage objects in frame 1 of the loaded swf.

  • Loading external swf file in a new window

    Hi,
    I've got a few .swf files with video tutorials I've created using Captivate 4.
    I wanted to link them so I've created a main screen with menu with buttons in Flash.
    I've added AS to load the external swf files but they load in the same window. How can I load these .swf files in seperate window so that you could get back to the main window after you've finished watching?
    Here's my code:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        myLoader.load(myURL);
        addChild(myLoader);
    I'm also attaching screenshot with menu in flash

    I've deleted the line and now the code lookes like that:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        addChild(myLoader);
    Unfortunately, it doesn't load the .swf file when you click on the button...

Maybe you are looking for

  • RMBP + External Monitor + SwitchResX Issue

    Hey guys. I am currently using a rMBP 15" with an Acer K272 external monitor. I am using the program SwitchResX to run the monitor in HiDPI mode (2560x1440 running at 2048x1152 hidpi). However, I get this weird bug when opening the lid of my mac. Whe

  • "loopback" counter output without wiring

    Cross posted from another forum for more visibility: Basically, I have a counter output being generated on a trigger line. It's just a pulse at defined intervals of 1 hz. The problem is, the card that is generating the output needs the trigger itself

  • Bold shutdowns

    For the past 5months now, my Bold 5 shutdown during charging and has not been able to power on since then. I have asked one or two local techicians to check yet the smae. I have plugged to my computer no response. which way out now.?

  • Datepicker mindate based on another item

    Hi, Is it possible to change the mindate property of a date picker based on the value of another item? For example: P01_ITEM1 = datepicker P01_ITEM2 = datepicker I would like to set the mindate property of P01_ITEM2 as the selected date of P01_ITEM1.

  • Navigation arrows in RoboHelp 7?

    Are these arrrow no longer available? I have the bread crumbs but can't find the navigational arrows we used to insert on each page. Thanks, Rich