How to unload an SWF

Hi All,
I have a problem working with SWFLaoder, I have loaded one
SWF(child) file inside another SWF(Parent) using an SWFLoader.Now I
have a "Back" button in second SWF(Child) on click of that button i
have to unload the current SWF(child) and and move back to my
(Parent) SWF. How can i achieve this. Please suggest me.
Cheers,
Chandu

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

Similar Messages

  • How to unload/load swf

    I have a Flash movie that automatically opens another Flash movie inside it. The main swf has a "Start" button at the bottom. When I click the Start button I want to unload the swf that loaded automatically (as a placeholder) and load a new Flash video swf. I'm doing this to create a placeholder for the video. I don't know what code I need to use on the button to unload the automatic swf and load the new swf video.

    if you don't need to stop any loaded streams (like sound/video), you can just reuse the same loader to load the next swf.  otherwise, apply unloadAndStop() to your loader before loading the next swf.

  • How to unload swf file?

    I was wondering what are the codes for unloading the swf file after i hit the return button key????
    I tried removeChild(); but still exits in the menu page after i hit the return button key.

    no.  if you're not using a loader to load a swf, you can't use the unload() method.  and there is no unLoad() method.
    if you want to remove everything from the stage in your main swf, you can use removeF() from the main timeline:
    removeF(this);
    function removeF(mc):void{
    for(var i:int=0;i<mc.numChildren;i++){
        mc.removeChildAt(0);

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

  • Need help unloading an .swf

    I'm using flash CS5, AS3
    I'm making a huge module that has a central "Hub" (table of contents) which contains all links to the other slides which are individual .swf files.
    The issue is, from the main hub, i click on the link to open a swf and it starts to play.  if the button that returns you to the Hub is pushed before the whole .swf plays through, the symbols and tweens from the swf that was just unloaded, still show up on top of the Hub and keep playing.  anyone know how i can fix this?
    code in frame 1 of all swfs:
    this.btn_hub.addEventListener(MouseEvent.CLICK, SWFhub);
    var fl_Loader:Loader;
    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad:Boolean = true;
    function SWFhub(event:MouseEvent):void
            fl_Loader.unload();
            removeChild(fl_Loader);
            fl_Loader = null;
            fl_Loader = new Loader();
            fl_Loader.load(new URLRequest("Slide HUB.swf"));
            addChild(fl_Loader);
        SoundMixer.stopAll();
    any help would be appreciated!
    -= Sondax =-

    a few issues...  for the code that goes on the loaded swf, the button doesn't return you back to the hub.  i changed the first line to "this.btn_hub.addEventListener(MouseEvent.CLICK,unloadF);", but still doesn't work.  (btn_hub is name of button that returns you to the hub)
    for the hub, when i copy and paste the code to add buttons for the other slides, i get errors of duplicate functions:
    Scene 1, Layer 'actions', Frame 1, Line 29
    1151: A conflict exists with definition fl_Loader in namespace internal.
    Scene 1, Layer 'actions', Frame 1, Line 41
    1021: Duplicate function definition.
    Scene 1, Layer 'actions', Frame 1, Line 45
    1021: Duplicate function definition.
    line 29 = var fl_Loader:Loader=new Loader();
    line 41 = function completeF(e:Event):void{
    line 45 = function unloadF(e:Event):void{
    the full code in the hub (just 2 buttons added so far):
    stop();
    this.btn_62.addEventListener(MouseEvent.CLICK, SWF62);
    var fl_Loader:Loader=new Loader();
    fl_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeF) ;
    function SWF62(event:MouseEvent):void
    if(fl_Loader.content){
    unloadF(event);
            fl_Loader.load(new URLRequest("Slide6_2.swf"));
            addChild(fl_Loader);
    function completeF(e:Event):void{
    MovieClip(fl_Loader.content).addEventListener("unload",unloadF);
    function unloadF(e:Event):void{
    MovieClip(fl_Loader.content).removeEventListener("unload",unloadF);
    fl_Loader.unloadAndStop();
    this.btn_11.addEventListener(MouseEvent.CLICK, SWF11);
    var fl_Loader:Loader=new Loader();
    fl_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeF) ;
    function SWF11(event:MouseEvent):void
    if(fl_Loader.content){
    unloadF(event);
            fl_Loader.load(new URLRequest("Slide1_1.swf"));
            addChild(fl_Loader);
    function completeF(e:Event):void{
    MovieClip(fl_Loader.content).addEventListener("unload",unloadF);
    function unloadF(e:Event):void{
    MovieClip(fl_Loader.content).removeEventListener("unload",unloadF);
    fl_Loader.unloadAndStop();

  • 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");

  • 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");

  • Unloading external swf problem - deadline approaching

    Hi,
    We bought a component, and the developers are not real
    helpful so I thought I would try here. We have the well-known AS 3
    problem of events continuing to run even after you've unloaded a
    swf. Here is what we got:
    a main swf loads one of 7 secondary swfs, based on a button
    click. each of the secondary swfs contains the component (a 3D
    wall) that we purchased. we don't seem to have access to the code.
    we unload one swf load the next, and then after we do this a few
    times we get the following crash (output way below).
    The component does have a closeWall() function, which i'm
    assuming cleans things up. The problem is I don't know how to call
    a function on an externally loaded swf? Is that possible? In other
    words I want to say:
    var loader:Loader;
    function loadSwf(){
    loader = new Loader();
    var urlRequest:URLRequest = new URLRequest ("vidSub.swf");
    loader.load(urlRequest);
    addChildAt(loader, getChildIndex(holder));
    function unloadSwf(){
    // hey swf, close properly, before I unload you
    loader.closeWall();//or something like this
    loader.unload();
    Thanks so much if you can help.
    Doug
    Crash output:
    Error: Error #2094: Event dispatch recursion overflow.
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.display::Stage/dispatchEvent()
    at
    org.papervision3d.core.utils.virtualmouse::VirtualMouse/::handleUpdate()
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at
    org.papervision3d.core.utils.virtualmouse::VirtualMouse/update()
    at
    org.papervision3d.core.utils.virtualmouse::VirtualMouse/setLocation()
    at
    org.papervision3d.core.utils::InteractiveSceneManager/org.papervision3d.core.utils:Intera ctiveSceneManager::handleMouseMove()
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.display::Stage/dispatchEvent()
    at org.papervision

    I feel for you...
    You may want to try to instantiate the thing not through
    adding loader to display list but accessing application domain and
    creating an instance of its class. Some application will not do a
    thing if you just add them to display list and accessing their
    interfaces (I love doing that for one :-). In any case - I am not
    sure it is such a good idea to add the loader directly - not within
    INIT event listener.
    You may want to try accessing their application domain and
    loop through its properties to see which ones are enumerable. In
    the error stack you can see some their classes so you know already
    what to access. For instance there is
    org.papervision3d.core.utils.InteractiveSceneManager class.
    I don't say anything new but it looks like there is the same
    event flying around which is dispatched by some listener causing
    recursion. Can it be that your custom events have the same type as
    theirs? Try to listen to their events through making listener
    listen in capture phase by setting third parameter to true:
    blah.addEventListener("eventType", eventHandler, true) - you may be
    able to explicitly remove their event listener if you know which
    one. Or, perhaps, this is your mouse event that conflicts with
    theirs...
    Sorry I cannot be more helpful.

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

  • How to create the SWF file which was included surrogate pairs.

    I would like to make sure how to create the SWF file which are included surrogate pairs.
    The error of outside the scope of unicode occurred when I compiled(mxmlc) the as file which was set surrogate pairs to 'Unicoderange'.
    Ex, I set the '  '(UTF-16 is '20B9F') to 'Unicoderange'.
    However, I cannot add the surrogate pairs.
    The error of outside the scope of Unicode occurred when I compiled the AS file.
    The reason of error was that the Unicode(UTF-16) of surrogate pairs is invalid.
    Then, I read the following pages.
    These pages are written that unicode-range supported surrogate pairs.
    http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_07.html
    http://www.w3.org/TR/1998/REC-CSS2-19980512/fonts.html#descdef-unicode -range
    So please let me know how to create the SWF file which are included surrogate pairs.
    Environment
    - Flex3.5a
    - TTC: meiryo(ver6.02), msgothic(ver2.50), mspgothic(ver2.50)
    Thanks,
    Takeshi Ishihara.

    I've been able to create project jar files in Eclipse by selecting Export from the File menu, then choose Java - Jar file - and provide the required information, name, destination folder etc. But when I do this, I do not export other jars on the build path this way nor do I expect to do this. I am only concerned with creating a jar file of my own work. A jar file does not "contain" other jar files. If the jar file contains the main method, and requires other jars for it's execution, then you may wish to include a reference to required jars on the class path entry of the Manifest file of the jar file you create. I'm not sure how to create a Manifest file in eclipse though..

  • How to put the swf in sub directory

    Would you guys let me know how to put the *.swf file which
    has *.flv in sub directory other than root.
    I've tried many things none of them working.
    a regular *.swf are OK. But if that swf file related with
    *.flv. that Swf has to be in root directory on the server.
    if I put that swf in sub directory such as /swf then it's not
    working.
    Please, help me out.

    Hi,
    It looks like this is for the certification, so I won't give you that much helpt. But you could use a modern IDE to do what you want, or use ant (http://ant.apache.org/) for building.
    /Kaj
    Ps. It looks like your classpath is wrong when you try to run the program.

  • How to Preloading a swf file in one application

    hello friends,
    How to preload a swf file in one application??
    i have two panel in one panel i given login screen and In second panel there is one module i have to show this panel which is visible="false" when user logged in but i have to preload this module in second panel when the user is doing logi. and when user logged in that time i have to show the second panel hiding the first panel.
    so how to do this i m not getting can anyone help me??
    Thanking you,
    Gajanan

    i have created a jar file.Now i want to reuse this
    jar file in another java program.Could anyone please
    guide me with the steps of how to reuse a jar fileput your jar file in class path and import the class which u want to reuse in your code so that u can access all the methods in that class in ur code.

  • Transition_Manager and unloading external swf problems

    Hi there
    I´m having a few problems with my project which i although it work it has some unpleasant bugs that i´m trying to solve for days.
    When i load external swf´s they show up on top of the Menu button.Maybe because the button i´m pressing is inside the same movieclip as the Menu.
    Explaining better here´s a little diagram of my site:
    con2 MC (Instance of Menu) ---> cont3 MC (Instance of subMenu) and mainButton MC (Instance of Main)
    Here´s the general code which is inside the Painel.as
    package {
        import com.greensock.TweenLite;
        import com.greensock.TweenMax;
        import com.greensock.*;
        import com.greensock.easing.*;
        import flash.display.*;
        import flash.events.*;
        import flash.display.MovieClip;
        import fl.transitions.*;
        import fl.transitions.easing.*;
        import flash.net.URLRequest;
        import flash.display.Loader;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        public class Painel3 extends MovieClip
            private var inFocus:MovieClip;
            public function Painel3():void
                setupClips();
                addEventListener(Event.ENTER_FRAME, loop);
            private function setupClips():void
            con2.mainButton.addEventListener(MouseEvent.ROLL_OVER, onOver);
            con2.mainButton.addEventListener(MouseEvent.ROLL_OUT, onOut);
            con2.mainButton.addEventListener(MouseEvent.CLICK, onClick);
                var len:int = con2.cont3.numChildren;
                for(var i:int=0; i<len; i++)
                    var mc:MovieClip = MovieClip(con2.cont3.getChildAt(i));
                    mc.buttonMode = true;
                    mc.loc = [mc.x, mc.y];
                    mc.addEventListener(MouseEvent.CLICK, onClick);
                    con2.cont3.visible = false;
            private function onOver(e:MouseEvent):void
            private function onOut(e:MouseEvent):void
            private function onClick(e:MouseEvent):void
                con2.cont3.visible = true;
    TransitionManager.start(con2.cont3, {type:Wipe, direction:Transition.IN, duration:1, easing:None.easeNone, startPoint:5} );                       
            private function loop(e:Event):void
                var distx:Number = mouseX / 1400;
                var disty:Number = mouseY / 1400;
                TweenLite.to(con2, 2, {
                            rotationY:(-70 +(145*distx)),
                            rotationX:(70 -(145*disty)),
                            ease:Expo.easeOut
    And then inside the subMenu.as class for the movieclip subMenu i have the buttons that load the external swf´s:
    package  {
        import com.greensock.TweenLite;
        import com.greensock.TweenMax;
        import com.greensock.*;
        import com.greensock.easing.*;
        import flash.display.*;
        import flash.events.*;
        import flash.display.MovieClip;
        import flash.net.URLRequest;
        import flash.display.Loader;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        import fl.transitions.*;
        import fl.transitions.easing.*;
        public class subMenu extends MovieClip {
            public function subMenu() {
                // constructor code
                menu1.buttonMode = true;
                menu2.buttonMode = true;
                menu3.buttonMode = true;
                menu4.buttonMode = true;
                 menu1.addEventListener(MouseEvent.CLICK,link1);
                 menu2.addEventListener(MouseEvent.CLICK,link2);
                 menu3.addEventListener(MouseEvent.CLICK,link3);
                 menu4.addEventListener(MouseEvent.CLICK,link4);
            function link1(e:MouseEvent) {
               function startLoad()
                var mLoader:Loader = new Loader();
                var mRequest:URLRequest = new URLRequest("AugmentedReality_v1.swf");
                mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
                mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
                mLoader.load(mRequest);
    function onCompleteHandler(e:Event):void {
    var swf:DisplayObject = e.target.content;
    swf.x = -400;    
    swf.y = -300;    
    addChild(swf);
    function onProgressHandler(mProgress:ProgressEvent)
           var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
           trace(percent);
    startLoad();
            function link2(e:MouseEvent) {
                function startLoad()
                var mLoader:Loader = new Loader();
                var mRequest:URLRequest = new URLRequest("Fotos.swf");
                mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
                mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
                mLoader.load(mRequest);
    function onCompleteHandler(e:Event):void {
    var swf:DisplayObject = e.target.content;
    swf.x = -400;    
    swf.y = -300;    
    addChild(swf);
    function onProgressHandler(mProgress:ProgressEvent)
           var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
           trace(percent);
    startLoad();
            function link3(e:MouseEvent) {
            function link4(e:MouseEvent){
                function startLoad()
                var mLoader:Loader = new Loader();
                var mRequest:URLRequest = new URLRequest("Texto.swf");
                mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
                mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
                mLoader.load(mRequest);
    function onCompleteHandler(e:Event):void {
    var swf:DisplayObject = e.target.content;
    swf.x = -400;    
    swf.y = -300;    
    addChild(swf);
    function onProgressHandler(mProgress:ProgressEvent)
           var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
           trace(percent);
    startLoad();
    Like i said the swf´s show up on top of the Menu and i need it to dissapear.
    Also i want to unload the swf currently in scene so that when i load another one they don´t pile on top of each other.
    Pls help. Thanks

    Oh btw, i´m having an error 1069 Property TransitionManager not found in subMenu and there is no default value
    at fl.transitions::TransitionManager$/start()
        at Painel3/onClick()
    This doesn´t happen when i uncheck the Export for actionscript in the subMenu class but i can´t do that or else the buttons wont work.

Maybe you are looking for

  • FaceTime not working on any of my apple products

    Cannot connect on any of my apple products to FaceTime this evening, iPad iPhone or MacBook ?

  • Error in serialsation of simple transfromation to XMl

    1. i am getting  the below error during the call transformation error in serialsation of simple transfromation program xxxxxx Edited by: Dhandapani Satheeshkumar on Dec 10, 2009 5:11 PM

  • ITunes 6, !!!HELP!!!

    I always get problems with my iTunes. after i installed the latest version of windows media player classic, my iTunes decided not to play my music anymore. ...so, i thought the easiest and the fastest way to solve this prob is to just download iTunes

  • Text is exceeding Gantt chart bar

    Hi Experts I have a Gantt chart in a Webdynpro for Java application. I am showing some value (Label) on the bars of the chart. But if the bar is small the value is not fitting into the bar. Is there any way to controll it ? Thanks Sunit

  • Announcement of New WIKI on Business Object Attachments in SOFF/BDS/DMS/GOS

    https://wiki.sdn.sap.com/wiki/display/ABAP/RetrievingandManipulatingAttachmentstoSAPBusinessObjects%28SAPOffice%2CBDS%2CDMS%2CGOS%2C...%29 Narendran and aRS - People are anxiously awaiting your contributions to the WIKI, so please feel free to add wh