Unloading an External SWF

Hi,
I'm building a site that has 7 sections. 1 section is a Photo Gallery for which I'm loading an external SWF file that is controlled by an XML file. Im doing this for allowing content editing any time.
All of the other content on the site is one-time, no backend required.
I've successfully loaded the external swf file into a loader in one of the frames. However, when I navigate away to the other 6 sections, I'm unable to unload the external SWF loader. How do I go about this?
Here's my code that loads the external SWF in one frame:
import flash.events.MouseEvent;
//This creates a new instance of the loader object.
var my_Loader:Loader = new Loader();
//This creates a new instance of the URLRequest object that contains the
//path to the external SWF.
var my_url:URLRequest=new URLRequest("gallery.swf");
//These listeners detect when the file has finished loading, and if the
//correct file is loaded.
my_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
my_Loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
//The load method then loads the SWF file into the loader object.
my_Loader.load(my_url);
//This will offset the load SWF file, so be appear at (20, 20) on the stage.
my_Loader.x = 37.85;
my_Loader.y = 74.90;
//This function adds the external SWF to the stage.
function finishLoading(loadEvent:Event) {
addChild(loadEvent.currentTarget.content);
//This function displays a message if the file is not found.
function errorHandler(errorEvent:Event):void {
trace("file missing");
stop();
Here's the code I'm using for the site navigation buttons. I tried adding my_Loader.unload(); for all of the button Event listener functions. Its still not working.
import flash.events.MouseEvent;
vinaybtn.addEventListener(MouseEvent.CLICK, vinay);
function vinay(event:MouseEvent):void
    my_Loader.unload();
    gotoAndStop(2);
priyabtn.addEventListener(MouseEvent.CLICK, priya);
function priya(event:MouseEvent):void
    gotoAndStop(3);
gallerybtn.addEventListener(MouseEvent.CLICK, gallery);
function gallery(event:MouseEvent):void
    gotoAndStop(4);
bestwishesbtn.addEventListener(MouseEvent.CLICK, bestwishes);
function bestwishes(event:MouseEvent):void
    my_Loader.unload();
    gotoAndStop(5);
invitationbtn.addEventListener(MouseEvent.CLICK, invitation);
function invitation(event:MouseEvent):void
    gotoAndStop(6);
rsvpbtn.addEventListener(MouseEvent.CLICK, rsvp);
function rsvp(event:MouseEvent):void
    gotoAndStop(7);
Any help would be much appreciated.
Thanks,
Sudarshan

try:
var mc:MovieClip;
//This function adds the external SWF to the stage.
function finishLoading(loadEvent:Event) {
mc=loadEvent.currentTarget.content as MovieClip;
addChild(mc);
vinaybtn.addEventListener(MouseEvent.CLICK, vinay);
function vinay(event:MouseEvent):void
    removeChild(mc)
    gotoAndStop(2);

Similar Messages

  • Need help unloading an External .swf within another external .swf

    My main project loads an external .swf ("room") depending on which button the user clicks. Once that external .swf ("room") is loaded, the viewer chooses a ("demo") .swf to view. I need the "demo" .swf to unload once it is finished playing so that the viewer sees the 1st external .swfs menu again. All .swfs are loaded into an empty loader component. The "demo" swfs were created in captivate thus I don't have access to a timeline for them.
    I imported a .swf into captivate that will call a function at the end ie..._root.unloadCaptivate();
    and I have the following code in the originally loaded .swf
    function unloadCaptivate() {
    mcLoader.unloadClip(accountingLoader_mc);
    btnEndPeriod_btn.enabled = true;
    btnCashCollect_btn.enabled = true;
    btnFinancialMGMT_btn.enabled = true;
    _root.btnHome_mc._visible = false;
    btnAcct_mc._visible = false;
    btnPlay._visible = false;
    btnPause._visible = false;
    That all works fine, but when I load "room" .swfs into the main .swf, the unloadCaptivate(); no longer works...any ideas? Thanks!

    you should be able to use a loop (like onEnterFrame) to check when your demo swf's _currentframe==_totalframes.

  • 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

  • How to load and unload Multiple External SWF

    hello there,
    i need help to figuring out how to load and also unload(removing) multiple external SWF.
    so here is what i;m trying to do,
    i want to load multiple external SWF and play it on my main SWF now i hove no problem with just loading multiple SWF and placing it in the display list .The problem came up when i tried removing those loaded SWF from the display list ,The problem exist because i have no way to refer to what i have loaded and placed on the display list,
    i used a single loader instance to load all that external swf,
    i do know that we have to remove all the event listener related to the external SWF that we want to remove and for this purpose i have crated a function called destroy which the main objective for this function is to remove all event listener inside the swf and also isolating all variable so it would be eligible for garbage collecting, here is what the code look like:
    // Create this in every object you use
    public function destroy():void
         // Remove event listeners
         // Remove anything in the display list
         // Clear the references to other objects, so it gets totally isolated
    sorry it just a kind of pseudocode cause this function will customize with it's own property i did this just for the purpose of simplicity and easy understanding..,
    so now back to main problem how should i solve this problem??
    i tried used an arraf to save all the loaded swf
         the array is just used to save the what the loader is loading but the adding to display method is using
    movieClipActAsContainer.addChild(e.target.content); //the event is from the Event.COMPLETE
    but i have a hard time using that arrya back and matching it to the one i got from the display list.
    please do help me,
    any suggestion would be greatly appreciated,
    and if can pleas show me a source code or pseudocode of what you're suggesting to me cause my english is not so fluent yet,
    thanks before.

    Hey EI,
    I had done this kind of project recently and for loading and unloading different swfs. I had used loaders specific to that filename and for removing I had used a single movieclip instance name and on clicking that specific loader request name that needs to be removed will be requested from the specific function. As mentioned below
    Loading SWF:
    ===============================
    swfLoaderIndia.load(swfRequestIndia);//This will load the request
    If you are inside a movieclip while requesting use below code
    MovieClip(this.root).addChild(swfLoaderIndia);//This will load swf on stage
    or else
    Stage.addChild(swfLoaderIndia);
    Unloading SWF
    =====================================
    If you are inside a movieclip while requesting use below code
    MovieClip(this.root).removeChild(swfLoaderIndia);//This will unload swf on stage
    or else
    Stage.removeChild(swfLoaderIndia);
    Above code will be in specific function which will be requested when the loading and unloading is required.
    I hope this helps you in your project.
    With Regards,
    Sagar S. Ranpise

  • 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 / 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();

  • AS3 Unloading external SWF piling up problem

    I have two buttons on main SWF what loads and Unload two external SWFs back and forth.
    Also one timer function is calling external Screen saver SWF and unload the existing one when no interaction found.
    I am using unloadAndStop() function to unload the external SWFs.
    But after loading and unloading external SWFs, I am facing piling up or stack overflow problem.
    Any help will be highly appreciated.
    Thanks
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.media.Video;
    import flash.display.MovieClip;
    import caurina.transitions.*;
    import flash.utils.Timer;
    import flash.events.*;
    var myLoader_Map_1:Loader = new Loader();
    var myLoader_Map_2:Loader = new Loader();
    var myLoader_Screen_Saver:Loader = new Loader();
    var Ss:Boolean = false;
    var Maps:Boolean = true;
    //--------------------Screen Saver---------------------------------
    ScreenSaver();
      function ScreenSaver():void{
      var url:URLRequest = new URLRequest("screensaver.swf");
      myLoader_Screen_Saver.load(url); 
      addChild(myLoader_Screen_Saver);
      setChildIndex(myLoader_Screen_Saver, 1);
      Maps = false;
      Ss = true;
      function ScreenSaver_Unload():void{
      myLoader_Screen_Saver.unloadAndStop();
    //--------------------Map Buttons---------------------------------
    function MPstart():void{
      Tweener.addTween(MC_Maps_Btns,{alpha:1, x:778.25, y:1070.65, time:1, delay:1, transition:"easeOutCubic"});
      setChildIndex(MC_Maps_Btns, 2);
      MC_Maps_Btns.Btn_Map_1.visible = true;
      MC_Maps_Btns.Btn_Map_2.visible = true;
    function MPclose():void{
      Tweener.addTween(MC_Maps_Btns,{alpha:0, x:778.25, y:1179.85, time:1, transition:"easeOutCubic"});
    //--------------------Map 1 ---------------------------------
    MC_Maps_Btns.Btn_Map_1.addEventListener(MouseEvent.CLICK,OpenMap1);
      function OpenMap1(e:MouseEvent):void{
      var url:URLRequest = new URLRequest("Map_1.swf");
      myLoader_Map_1.load(url);
      myLoader_Map_1.alpha = 1;
      addChild(myLoader_Map_1);
      setChildIndex(myLoader_Map_1, 2);
      myLoader_Map_2.unloadAndStop();
      ScreenSaver_Unload();
      Maps = true;
      Ss = false;
      MC_Maps_Btns.Btn_Map_1.visible = false;
      MC_Maps_Btns.Btn_Map_2.visible = true;
    //--------------------Map 1 ---------------------------------
    MC_Maps_Btns.Btn_Map_2.addEventListener(MouseEvent.CLICK,OpenMap2);
      function OpenMap2(e:MouseEvent):void {
      var url:URLRequest = new URLRequest("Map_2.swf");
      myLoader_Map_2.load(url);
      myLoader_Map_2.alpha = 1;
      addChild(myLoader_Map_2);
      setChildIndex(myLoader_Map_2, 2);
      myLoader_Map_1.unloadAndStop();
      ScreenSaver_Unload();
      Maps = true;
      Ss = false;
      MC_Maps_Btns.Btn_Map_2.visible = false;
      MC_Maps_Btns.Btn_Map_1.visible = true;
    //--------------------Timer ---------------------------------
    var inactiveTime:int = 10000;
    var t:Timer = new Timer(inactiveTime);
    stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown1);
    t.addEventListener(TimerEvent.TIMER, onTimer);
    t.start();
      function onMouseDown1(e:MouseEvent):void {
      t.reset();
      t.start();
      trace("Interaction detected");
      function onTimer(e:TimerEvent):void {
      handleInactivity();
      function handleInactivity():void {
      trace('You\'re inactive.');
      if (Maps == true){
      myLoader_Map_1.unloadAndStop();
      myLoader_Map_2.unloadAndStop();
      else{
      trace("No Maps");
      if (Ss == false ){
      ScreenSaver();
      MPclose();
      else{
      trace("ScreenSaver already loaded");

    This is how I applied
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.media.Video;
    import flash.display.MovieClip;
    import caurina.transitions.*;
    import flash.utils.Timer;
    import flash.events.*;
    var myLoader_Map_1:Loader = new Loader();
    var myLoader_Map_2:Loader = new Loader();
    var myLoader_Screen_Saver:Loader = new Loader();
    var Ss:Boolean = false;
    var Maps:Boolean = true;
    //--------------------Screen Saver---------------------------------
    function unloadAllF():void{
    if(myLoader_Screen_Saver.content){
    myLoader_Screen_Saver.unloadAndStop();
    trace("ss unloaded");
    if(myLoader_Map_1.content){
    myLoader_Map_1.unloadAndStop();
    trace("map_1 unloaded");
    if(myLoader_Map_2.content){
    myLoader_Map_2.unloadAndStop();
    trace("map_2 unloaded");
    //etc
    ScreenSaver();
      function ScreenSaver():void{
      var url_ss:URLRequest = new URLRequest("screensaver.swf");
      unloadAllF();
      myLoader_Screen_Saver.load(url_ss); 
      addChild(myLoader_Screen_Saver);
      setChildIndex(myLoader_Screen_Saver, 1);
      Maps = false;
      Ss = true;
        function ScreenSaver_Unload():void{
      myLoader_Screen_Saver.unloadAndStop();
    //--------------------Map Buttons---------------------------------
    function MPstart():void{
      Tweener.addTween(MC_Maps_Btns,{alpha:1, x:778.25, y:1070.65, time:1, delay:1, transition:"easeOutCubic"});
      setChildIndex(MC_Maps_Btns, 2);
      MC_Maps_Btns.Btn_Map_1.visible = true;
      MC_Maps_Btns.Btn_Map_2.visible = true;
    function MPclose():void{
      Tweener.addTween(MC_Maps_Btns,{alpha:0, x:778.25, y:1179.85, time:1, transition:"easeOutCubic"});
    //--------------------Map 1 ---------------------------------
    MC_Maps_Btns.Btn_Map_1.addEventListener(MouseEvent.CLICK,OpenMap1);
      function OpenMap1(e:MouseEvent):void{
      var url_map_1:URLRequest = new URLRequest("Map_1.swf");
      unloadAllF();
      myLoader_Map_1.load(url_map_1);
      myLoader_Map_1.alpha = 1;
      addChild(myLoader_Map_1);
      setChildIndex(myLoader_Map_1, 2);
      myLoader_Map_2.unloadAndStop();
      ScreenSaver_Unload();
      Maps = true;
      Ss = false;
      MC_Maps_Btns.Btn_Map_1.visible = false;
      MC_Maps_Btns.Btn_Map_2.visible = true;
    //--------------------Map 1 ---------------------------------
    MC_Maps_Btns.Btn_Map_2.addEventListener(MouseEvent.CLICK,OpenMap2);
      function OpenMap2(e:MouseEvent):void {
      var url_map_2:URLRequest = new URLRequest("Map_2.swf");
      unloadAllF();
      myLoader_Map_2.load(url_map_2);
      myLoader_Map_2.alpha = 1;
      addChild(myLoader_Map_2);
      setChildIndex(myLoader_Map_2, 2);
      myLoader_Map_1.unloadAndStop();
      ScreenSaver_Unload();
      Maps = true;
      Ss = false;
      MC_Maps_Btns.Btn_Map_2.visible = false;
      MC_Maps_Btns.Btn_Map_1.visible = true;
    //--------------------Timer ---------------------------------
    var inactiveTime:int = 10000;
    var t:Timer = new Timer(inactiveTime);
    stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown1);
    t.addEventListener(TimerEvent.TIMER, onTimer);
    t.start();
      function onMouseDown1(e:MouseEvent):void {
      t.reset();
      t.start();
      trace("Interaction detected");
      function onTimer(e:TimerEvent):void {
      handleInactivity();
      function handleInactivity():void {
      trace('You\'re inactive.');
      if (Maps == true){
      myLoader_Map_1.unloadAndStop();
      myLoader_Map_2.unloadAndStop();
      else{
      trace("No Maps");
      if (Ss == false ){
      ScreenSaver();
      MPclose();
      else{
      trace("ScreenSaver already loaded");

  • Trouble unloading external swf's

    Hey, so firstly, I am completely new to Flash and know absolutely nothing :| But heres my problem:
    In one particular keyframe, I have five buttons on the left hand side of my stage, that when clicked, display an external swf on the right handside. It works perfect fine using the code below. However on this frame where all this is going on, I also have a back button that i want to link back to the home page. But I just CAN'T seem to get it to unload the external swfs as well as go back in the timeline Any assistance would be great! Cheers
    var Xpos:Number = 675;
    var Ypos:Number = 225;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swfs/pacman1000.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    loader.scaleX = 0.8;
    loader.scaleY = 0.8;
    addChild(loader);
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
    removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
    loader.load(newSWFRequest);
    loader.x = 690;
    loader.y = 275;
    loader.scaleX = 0.8;
    loader.scaleY = 0.8;
    addChild(loader);
    // Btn listeners
    pacman1000.addEventListener(MouseEvent.CLICK, btnClick);
    snake.addEventListener(MouseEvent.CLICK, btnClick);
    tetris.addEventListener(MouseEvent.CLICK, btnClick);
    spaceinvaders.addEventListener(MouseEvent.CLICK, btnClick);
    simon.addEventListener(MouseEvent.CLICK, btnClick);

    Oops sorry I forgot to put "function"!
    function onBackButtonClick(e:MouseEvent):void {
    Obviously your back button needs an event listener to call this function.
    Kenneth Kawamoto
    http://www.materiaprima.co.uk/

  • Load/ Unload external .swf

    ----------------------------------------
    vita | web | design | illustration
    "main" here
    I try to have external .swf on this "main" part of my flash
    design automatically using load actionscript.
    I have 3 different sets of actionscripts for load/unload.
    But, the problem is when I click vita or other menu on the
    top after loading "main" external .swf, they are overlapped.
    How can I unload the external .swf from the automatically
    loaded .swf?
    (As I know, there are mostly buttons to click on loading
    external .swf. But for my design, I want it loads automatically.)
    Thanks in advance for suggestions. Please let me know if my
    description/question is not clear to answer.

    Are you using AS2 or AS3. The approach is completely
    different for both.

  • 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 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

  • Unload external SWF using event dispatch

    Hi i am working on a flash website where i have a main movie named as Navigation where i have all the navigation buttons and drop menus. i am using switch case method to load multiples external SWFs. so as user clicks on any of the navigation button...it loads the external SWF
    now i have a close_btn in the loaded SWF and i simply want the unload the external SWF when user clicks on the close_btn.
    I come to know that i can do this by event dispach but i am not sure what code to put in external swf  so when close_btn is clicked it can access the unloader function in main movie and unload the External SWF.
    Could you Please help, Thank you !
    this is my code
    //--------main swf---------------------
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.URLRequest;
              home_btn.addEventListener(MouseEvent.CLICK,Click_To_Close);
              ourstory_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              facility_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              customers_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              sustainability_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              contactus_btn.addEventListener(MouseEvent.CLICK, clickHandler);
    //  Dropdown Menu1 Buttons
              menu1.menu_mc1.organicinitiative_btn.addEventListener(MouseEvent .CLICK, clickHandler);
              menu1.menu_mc1.myhope_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              menu1.menu_mc1.target2015_btn.addEventListener(MouseEvent.CLICK, clickHandler);
    //  Dropdown Menu2 Buttons
              menu2.menu_mc2.mens_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              menu2.menu_mc2.womans_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              menu2.menu_mc2.teans_btn.addEventListener(MouseEvent.CLICK, clickHandler);
              menu2.menu_mc2.babies_btn.addEventListener(MouseEvent.CLICK, clickHandler);
    var loader:Loader = new Loader();
    addChildAt(loader,0);
    function clickHandler(e:Event):void{
    switch(e.target.name){
        case "ourstory_btn": loader.load(new URLRequest("ourstory.swf")); break;
        case "facility_btn": loader.load(new URLRequest("facility.swf")); break;
              case "customers_btn": loader.load(new URLRequest("customers.swf")); break;
              case "sustainability_btn": loader.load(new URLRequest("sustainability.swf")); break;
              case "contactus_btn": loader.load(new URLRequest("contactus.swf")); break;
              case "organicinitiative_btn": loader.load(new URLRequest("organicinitiative.swf")); break;
              case "myhope_btn": loader.load(new URLRequest("myhope.swf")); break;
              case "target2015_btn": loader.load(new URLRequest("target2015.swf")); break;
              case "mens_btn": loader.load(new URLRequest("mens.swf")); break;
              case "womans_btn": loader.load(new URLRequest("womans.swf")); break;
              case "teans_btn": loader.load(new URLRequest("teens.swf")); break;
              case "babies_btn": loader.load(new URLRequest("babies.swf")); break;
    //-----------my unloader function in main swf --------------------
    function Click_To_Close(event:MouseEvent):void
                  if(loader != null) {
         loader.unloadAndStop();

    thank you
    i have tried to use   this.parent.Click_To_Close  but it gives compilation error
    i checked the tutorial about custom events i think its little complex for me now to understand the typeriter app.
    also i cheked the similer thread and tried to test that code myself..i found that the last block of main movie does not works and does not unload the loader2. however  all the trace are showing in the output windows that i added to check the code but last trace from the main movie is not showig...   
    trace("child removed from Main Movie") 
    so if this can work somehow i will use this method of event dispatch in my application that i am working...
    Thank you
    -----main movie ---------
    var loader1:Loader = new Loader();
    var loader2:Loader = new Loader();
    loader1.contentLoaderInfo.addEventListener(Event.COMPLETE, assignMovie1Listener);
    loader1.load(new URLRequest("movie_1.swf"));
    loader2.load(new URLRequest("movie_2.swf"));
    addChild(loader1);
    addChild(loader2);
    function assignMovie1Listener(evt:Event):void {
          MovieClip(evt.currentTarget.content).addEventListener("eventTriggered", removeLoader2);
                trace("listner is listning..")
    function removeLoader2(evt:Event):void {
          loader2.unloadAndStop();
          removeChild(loader2);
             loader2 = null;
                trace("child removed from Main Movie")
    //------------- movie_1.swf code:
    removeMovie2_btn.addEventListener(MouseEvent.CLICK , removeMovie2);
    function removeMovie2(event:MouseEvent):void
          dispatchEvent(new Event("eventTriggered"));
                trace("event triggered form Child Movie-1");
    as u can see when i click close button its triggering the trace from movie-1 but its not unloadign the movie2

  • 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

  • Buttons and external swfs

    I would like to automatically load an external swf inside an existing empty mc (or a new one)  and load/unload different external swf on several button click fuctions.  I've read the other posts, but none that quite facilitates accomplishing this.
    This is what I have, I know it's messy- but I've been trying so many different methods until its probably loaded with irrelevant functions!
    var myLoader:Loader = new Loader(); addChild(myLoader); var url:URLRequest = new URLRequest("homepage.swf"); myLoader.load(url);
      myLoader.x=477;
      myLoader.y=0;
    /* Click to Load/Unload SWF or Image from a URL.
    Clicking on the symbol instance loads and displays the specified SWF or image URL. Clicking on the symbol instance a second time unloads the SWF or image.
    Instructions:
    1. Replace "http://www.helpexamples.com/flash/images/image1.jpg" below with the desired URL address of the SWF or image. Keep the quotation marks ("").
    2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.
    button_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;
    function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
    if(fl_ToLoad)
      fl_Loader = new Loader();
      fl_Loader.load(new URLRequest("homepage.swf"));
      fl_Loader.x=477;
      fl_Loader.y=0;
      removeChild(myLoader);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_4
      addChild(fl_Loader);
    else
      fl_Loader.unload();
      removeChild(fl_Loader);
      removeChild(myLoader);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_4);
      fl_Loader = null;
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad = !fl_ToLoad;
    /* Click to Load/Unload SWF or Image from a URL.
    Clicking on the symbol instance loads and displays the specified SWF or image URL. Clicking on the symbol instance a second time unloads the SWF or image.
    Instructions:
    1. Replace "http://www.helpexamples.com/flash/images/image1.jpg" below with the desired URL address of the SWF or image. Keep the quotation marks ("").
    2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.
    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("portfolio.swf"));
      fl_Loader_2.x=477;
      fl_Loader_2.y=0;
      removeChild(myLoader);
      removeChild(fl_Loader);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_4);
      addChild(fl_Loader_2);
    else
      fl_Loader_2.unload();
      removeChild(fl_Loader_2);
      removeChild(fl_Loader);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_4);
      fl_Loader_2 = null;
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad_2 = !fl_ToLoad_2;
    /* Click to Load/Unload SWF or Image from a URL.
    Clicking on the symbol instance loads and displays the specified SWF or image URL. Clicking on the symbol instance a second time unloads the SWF or image.
    Instructions:
    1. Replace "http://www.helpexamples.com/flash/images/image1.jpg" below with the desired URL address of the SWF or image. Keep the quotation marks ("").
    2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.
    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("about.swf"));
      fl_Loader_3.x=477;
      fl_Loader_3.y=0;
      removeChild(myLoader);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader);
      removeChild(fl_Loader_4);
      addChild(fl_Loader_3);
    else
      fl_Loader_3.unload();
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader);
      removeChild(fl_Loader_4);
      fl_Loader_3 = null;
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad_3 = !fl_ToLoad_3;
    /* Click to Load/Unload SWF or Image from a URL.
    Clicking on the symbol instance loads and displays the specified SWF or image URL. Clicking on the symbol instance a second time unloads the SWF or image.
    Instructions:
    1. Replace "http://www.helpexamples.com/flash/images/image1.jpg" below with the desired URL address of the SWF or image. Keep the quotation marks ("").
    2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.
    movieClip_4.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_4);
    var fl_Loader_4:Loader;
    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad_4:Boolean = true;
    function fl_ClickToLoadUnloadSWF_4(event:MouseEvent):void
    if(fl_ToLoad_4)
      fl_Loader_4 = new Loader();
      fl_Loader_4.load(new URLRequest("contact.swf"));
      fl_Loader_4.x=477;
      fl_Loader_4.y=0;
      removeChild(myLoader);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader);
      addChild(fl_Loader_4);
    else
      fl_Loader_4.unload();
      removeChild(fl_Loader_4);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader);
      fl_Loader_4 = null;
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad_4 = !fl_ToLoad_4;

    Kglad I read up on that but it's still not stopping.I'm publishing for  fp 10 and have tried several different variations including:
    function gofolio (e:MouseEvent):void{
    imageLoader.load(navfolio);
    addChild(imageLoader);
    imageLoader.unloadAndStop(true);
    folio_btn.addEventListener(MouseEvent.CLICK, gofolio);
    function goabout (e:MouseEvent):void{
    imageLoader.load(navabout);
    addChild(imageLoader);
    imageLoader.unloadAndStop(true);
    removeChild(imageLoader)
    imageLoader=null
    about_btn.addEventListener(MouseEvent.CLICK, goabout);
    ....still not working.

Maybe you are looking for