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.

Similar Messages

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

  • How to load and unload external .swfs in a main .fla then load another external .swf on top

    I know that the question sounds confusing. I am new to AS3 but a little dangerous with it.
    The project
    I'm putting together a website tour with has a main .fla with navigation buttons. The navigation buttons load external .swfs using X and Y properties. Every external .swf houses a scrubber bar, play pause buttons which calls to a movie clip which houses the animation.
    The problem:
    Everything was working great, until someone mentioned "Hey, what if at the end of each loaded external .swf, a button appears that says "go to next section".
    So basically we are trying to give the user another way to get to the next section in the left hand navigation once the animation ends, in addition to being able to click in the left hand navigation for the next section. It's kind of like when a youTube video ends and it displays a button to go to the next movie that's in line, but you can also do it in the thumnail navigation as well.
    Ok, let's try it. Well, after many nights, searching the web and trying everything I am waving the white flag. I went through the lynda.com book over and over but I get an error message when I add code related to the parent timeline. I can actually get the next section to load on top of the previously loaded .swf, but it's buggy and I think the previous section is showing through underneath. Plus the scrubber isn't really working right. Since every .swf has a scrubber to control it, shouldn't it just load on top of the previous .swf? Do I need to add coding related to the parent timeline?
    I don't know if I should paste my code here, I have a sample .fla too. Help is so greatly appreciated!!!! If this can work, I think it would be very useful for anyone else doing something like this - I would definitely share any knowledge gained!
    Thanks.
    Jen

    If you want to utilize that code as a starting point (hopefully you understand what it does, and that the code actually works), then you need to modify it such that the array at the start has your filenames instead of the three it now shows, and the three buttons it uses are changed to the next and previous buttons you intend to use.  Here are the functions you need to make adjustments to...
    function onCompletePreloading():void {
            _loadedSWFs = 0;
            contentContainer.addChild(_swfClipsArr[_loadedSWFs]);
            next_btn.addEventListener(MouseEvent.CLICK, setContent);
            prev_btn.addEventListener(MouseEvent.CLICK, setContent);
    function setContent(event:MouseEvent):void {
            var _swfToAdd:MovieClip;
            if(event.currentTarget.name == "next_btn") {
                _loadedSWFs += 1;
                if(_loadedSWFs == _swfClipsArr.length){
                       _loadedSWFs = 0;
            } else if(event.currentTarget.name == "prev_btn"){
                _loadedSWFs -= 1;
                if(_loadedSWFs == -1){
                       _loadedSWFs = _swfClipsArr.length-1;
            _swfToAdd = _swfClipsArr[_loadedSWFs];
            contentContainer.removeChildAt(contentContainer.numChildren-1);
            contentContainer.addChild(_swfToAdd);
            trace(_swfToAdd.customID);

  • Load and unload external swf

    I'm simply trying to load external .swfs at different stages
    within my flash movie, as selected by the user.
    The problem i'm having is that once a .swf is loaded it stays
    loaded. I would like it to disappear when the user navigates to a
    different part of the main flash movie.
    Here's what i'm using:
    _root.createEmptyMovieClip("container",1);
    container.loadMovie("EXTERNALMOVIE.swf");
    container._x = container._y = 50 ;
    Help much appreciated!

    Obviously this went unanswered due to the easy way of using the loader component.
    So simple !
    RDemtl

  • Problem with loading and unloading external swfs

    Hello Forum,
    I'm pretty new to as3, and it's giving me a great challenge. I have a large number of captivate files that I want to play inside a simple container built in CS5.5... but switching back and forth between all the movies hogs the memory like crazy, so I need something to clean it up. All code is in a single frame on the main timeline. First, I create the loader:
    var FlashLoader:Loader = new Loader();
    var flashUrl:URLRequest = new URLRequest("placeholder.swf");
    FlashLoader.load(flashUrl);
    addChild(FlashLoader);
    The actual movies are located via an XML... but as I said the memory problem is huge, so I tried to build something to get rid of that. Ideally, I want the loader to clean up everything and start life anew with a single mouse click, like so:
    function _mouseClickHandler2(event:MouseEvent):void {
              FlashLoader.unloadAndStop();
              FlashLoader.parent.removeChild(FlashLoader);
              FlashLoader = null;
              var flashUrl:URLRequest = new URLRequest(event.target.href);
              var FlashLoader:Loader = new Loader();
              addChild(FlashLoader);
              FlashLoader.load(flashUrl);
              FlashLoader.x = 120;
              setChildIndex(FlashLoader,0);
              trace(FlashLoader.parent.numChildren);
    //          System.gc();
    //          System.gc();
    //          try {
    //                    new LocalConnection  .connect('gc');
    //                    new LocalConnection  .connect('gc');
    //          } catch (e: * ) {
    //          trace(getMemory ());
    //trace(event.target.href);
    //trace(event.target.text);
    Upon clicking on the menu (and thus switching movies), I get the following error:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
              at Treeview_working_fla::MainTimeline/_mouseClickHandler2()
    And this doesn't make sense to me. The FlashLoader is given a placeholder swf at the beginning, so why would the FlashLoader inside the function be recognized as having a null object reference?
    Thanks in advance

    In my quest to tackle this problem, I've decided to try and isolate the problem, and have made a simple "click to load, click to unload" when I stumbled upon a curious problem. The movie loads fine, and the UNLOAD function upon mouseclick also works perfectly. However, upon clicking again to activate RELOAD, it gives the error "No active security context" and refuses to load the same exact swf with the same exact path that successfully loaded the first time!
    import flash.events.MouseEvent;
    import flash.display.Loader;
    import flash.net.URLRequest;
    var FlashLoader:Loader = new Loader();
    var flashUrl:URLRequest = new URLRequest("folder/subfolder/movie.swf");
    FlashLoader.x = 120;
    FlashLoader.load(flashUrl);
    stage.addChild(FlashLoader);
    stage.addEventListener(MouseEvent.CLICK, UNLOAD);
    function UNLOAD(event:MouseEvent) {
              flashUrl = null;
              stage.removeChild(FlashLoader);
              FlashLoader.unloadAndStop();
              stage.removeEventListener(MouseEvent.CLICK, UNLOAD);
              stage.addEventListener(MouseEvent.CLICK, RELOAD);
    function RELOAD(event:MouseEvent) {
              var FlashLoader:Loader = new Loader();
              var flashUrl:URLRequest = new URLRequest("folder/subfolder/movie.swf");
              FlashLoader.x = 120;
              FlashLoader.load(flashUrl);
              stage.addChild(FlashLoader);
              stage.removeEventListener(MouseEvent.CLICK, RELOAD);
              stage.addEventListener(MouseEvent.CLICK, UNLOAD);

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

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

  • Unable to unload external swf which is using runtime sharing

    Unable to unload external swf which is using runtime sharing of some symbols and classes.
    Due to this problem i am unable to load another swf or the same for the second time and getting errors at runtime.
    It works fine when the swf is opened in IE.
    Can anyone please help me in solving the issue.

    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

  • I want to load external swf in movieclip and next external swf should load Automatically

    I want to load external swf in movieclip and next external swf should load Automatically when current swf is finished in AS3.
    How can we can check total frame and current frame of imported swf in a movie clip.
    any help will be appreciated
    regards,
    Jatin Dembla

    in as3 you use the loader class (not movieclips) to load external swfs.
    you can use an Event.COMPLETE event listener (applied to the loader's contentLoaderInfo property) to check when loading is complete and start the next swf loading.
    you can use the loader's content property (caste as a movieclip) to determine info (including totalFrames) about the loaded swf's main timelnie (once loading is initialized, for the totalFrames, or complete, for some other properties like height and width).
    var loader:Loader=new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadcompleteF);
    loader.load(new URLRequest("swf1.swf"));
    var loadedSWF:MovieClip;
    function loadcompleteF(e:Event):void{
    loadedSWF=MovieClip(loader.content);
    trace(loadedSWF.totalFrames);

  • Problem with Error 5005 and with external SWF loading

    I am creating a relatively simple 10-12 minute animation. I've broken the animation into 34 different movie clips that I control on the timeline by using a timer delay.
    When I try to export them all together I get the error:
    ",Line 1: Error 5005: Unknown Error optimizing byte code."
    However, when I split the presentation into two halves with the same exact frames and code I don't have the problem.
    I thought loading an external SWF at the end of the first movie would be a good way to connect everything. However, the SWF continuously loads and won't play through the way it looks when you open the actual SWF file.
    This is my code for the external loading:
    var xpos:Number = 0;
    var ypos:Number = 0;
    var swf:MovieClip;
    var myLoader:Loader = new Loader();// create a new instance of the Loader class
    var url:URLRequest = new URLRequest("aamc-2e-slide1.swf");// in this case both SWFs are in the same folder
    myLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);
    myLoader.load(url);
    function doneLoading(evt:Event):void
              trace("doneloading");
              swf = MovieClip(myLoader.content);
              stage.addChild(swf);
              swf.stop();

    I have the same/similar issue whether the stop is there or not.
    Yes, it is all on one frame.
    Without the stop, the SWF just continously loops on top of itself.

  • Fully loaded and rendered external SWF printing problem.

    I have an application that loads external SWF files that I have not built and do not have the codebase for.
    I need to know when these SWFs are fully loaded and have rendered themselves on the screen.
    Even gone to the point of giving them 80 enter frame events before trying to print and they show up on the paper sporadically.
    Does anyone know if there's some standard event coming from some object internal to SWFLoader that would let me know when the SWF is "running?"

    There is no way to know in the general case.  If it had an animation of
    birds flying around on it, when would be the right time to print it?

  • UNLOADING EXTERNAL SWF. SOMEONE HELP!

    I have a menu in my site and i recently added a comment form that is loaded when you click one of the buttons of the menu.
    My problem is that when I click on a different menu button the external swf [comment form] its still there I've tried adding the unloadMovie
    option but its not working. Here is the code for both buttons.
    ---------------------HOME BTN:
    on (rollOver) {
    gotoAndPlay(2);
    on (rollOut) {
    gotoAndPlay(6);
    on (release) {
    if (_root.choose != "home" && _root._currentframe!=30) {
    _root.play();
    _root.choose = "home";
    //mysound = new Sound();
    //mysound.attachSound("soundClick");
    //mysound.start();
    --------------------COMMENT FORM BTN:
    on (rollOver) {
    gotoAndPlay(2);
    on (rollOut) {
    gotoAndPlay(6);
    on (release) {
    if (_root.choose != "contact") {
    _root.play();
    _root.choose = "contact";

    unloadMovie() will work if there's a movie clip to be referenced. If you have assigned a name to the loaded movie you can unload it with unloadMovie(). Another option is to call unloadMovie() from the clip itself like: my_loaded_mc.unloadMovie(this); In every case check for incorrect paths (if you load a movie and refer to _root - the root will be the root of the loader, not the movie itself)
    Emil Georgiev - Flash and Web Design

  • Unloading external swf file keeps memory usage growing up

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

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

  • Unloading external swf

    Hello everyone,
    I'm kind of new to AS3
    I created a flash file and i have several buttons on the main
    stage.
    I have given the buttons instance names and whenever a button
    is clicked an external swf is loaded on the main stage.
    The problem which occurred is that ehenever i click on the
    same button again i can see a glimpse of the previous swf that was
    loaded meaning that i didnt get rid of the swf on the click of
    another button.
    What i want to achieve is to load the external swf and then
    when i click on another button i wish for it to unload.
    Here is the code.
    var externalSWF6:URLRequest = new URLRequest("dress6.swf");
    var myLoader6:Loader = new Loader();
    button6.addEventListener(MouseEvent.CLICK, onButtonClick6);
    myLoader6.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
    swfLoading6);
    myLoader6.contentLoaderInfo.addEventListener(Event.COMPLETE,
    swfComplete6);
    function onButtonClick6(event:MouseEvent):void
    myLoader6.load(externalSWF6);
    function swfComplete6(event:Event):void
    addChild(myLoader6);
    myLoader6.x = 0
    myLoader6.y = 0
    function swfLoading6(event:ProgressEvent):void
    var externalSWF7:URLRequest = new URLRequest("dress7.swf");
    var myLoader7:Loader = new Loader();
    button7.addEventListener(MouseEvent.CLICK, onButtonClick7);
    myLoader7.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
    swfLoading7);
    myLoader7.contentLoaderInfo.addEventListener(Event.COMPLETE,
    swfComplete7);
    function onButtonClick7(event:MouseEvent):void
    myLoader7.load(externalSWF7);
    function swfComplete7(event:Event):void
    addChild(myLoader7);
    myLoader.x = 0
    myLoader.y = 0
    myLoader7.addEventListener("UnloadMe", unloadFunction7); //
    <-- My line
    function unloadFunction7(event:Event):void {
    // event.target is the loader reference.. so cast it as
    Loader
    Loader(event.currentTarget).unload();
    function swfLoading7(event:ProgressEvent):void
    var externalSWF:URLRequest = new URLRequest("dress4.swf");
    var myLoader:Loader = new Loader();
    button4.addEventListener(MouseEvent.CLICK, onButtonClick);
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
    swfLoading);
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    swfComplete);
    function onButtonClick(event:MouseEvent):void
    myLoader.load(externalSWF);
    function swfComplete(event:Event):void
    addChild(myLoader);
    myLoader.x = 0
    myLoader.y = 0
    function swfLoading(event:ProgressEvent):void
    var externalSWF8:URLRequest = new URLRequest("dress8.swf");
    var myLoader8:Loader = new Loader();
    button8.addEventListener(MouseEvent.CLICK, onButtonClick8);
    myLoader8.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
    swfLoading8);
    myLoader8.contentLoaderInfo.addEventListener(Event.COMPLETE,
    swfComplete8);
    function onButtonClick8(event:MouseEvent):void
    myLoader8.load(externalSWF8);
    function swfComplete8(event:Event):void
    addChild(myLoader8);
    myLoader.x = 0
    myLoader.y = 0
    myLoader8.addEventListener("UnloadMe", unloadFunction8); //
    <-- My line
    function unloadFunction8(event:Event):void {
    // event.target is the loader reference.. so cast it as
    Loader
    Loader(event.currentTarget).unload();
    function swfLoading8(event:ProgressEvent):void
    var externalSWF9:URLRequest = new URLRequest("dress9.swf");
    var myLoader9:Loader = new Loader();
    button9.addEventListener(MouseEvent.CLICK, onButtonClick9);
    myLoader9.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,
    swfLoading9);
    myLoader9.contentLoaderInfo.addEventListener(Event.COMPLETE,
    swfComplete9);
    function onButtonClick9(event:MouseEvent):void
    myLoader9.load(externalSWF9);
    function swfComplete9(event:Event):void
    addChild(myLoader9);
    myLoader.x = 0
    myLoader.y = 0
    function swfLoading9(event:ProgressEvent):void
    //you can do something here while the swf is loading... }
    button4.buttonMode = true;
    button6.buttonMode = true;
    button7.buttonMode = true;
    button8.buttonMode = true;
    button9.buttonMode = true;
    button4.addEventListener(MouseEvent.ROLL_OVER,buttonOver4);
    button4.addEventListener(MouseEvent.ROLL_OUT,buttonOut4);
    function buttonOver4(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("over4");
    function buttonOut4(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("out4");
    button6.addEventListener(MouseEvent.ROLL_OVER,buttonOver6);
    button6.addEventListener(MouseEvent.ROLL_OUT,buttonOut6);
    function buttonOver6(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("over6");
    function buttonOut6(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("out6");
    button7.addEventListener(MouseEvent.ROLL_OVER,buttonOver7);
    button7.addEventListener(MouseEvent.ROLL_OUT,buttonOut7);
    function buttonOver7(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("over7");
    function buttonOut7(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("out7");
    button8.addEventListener(MouseEvent.ROLL_OVER,buttonOver8);
    button8.addEventListener(MouseEvent.ROLL_OUT,buttonOut8);
    function buttonOver8(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("over8");
    function buttonOut8(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("out8");
    button9.addEventListener(MouseEvent.ROLL_OVER,buttonOver9);
    button9.addEventListener(MouseEvent.ROLL_OUT,buttonOut9);
    function buttonOver9(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("over9");
    function buttonOut9(e:MouseEvent):void
    e.currentTarget.gotoAndPlay("out9");
    If anyone can be of assistance i would greatly appreciate
    it:)

    Your choices for removing objects are removeChild() and
    removeChildAt().
    So you need some way of tracking the objects that are added
    so that they can be removed. IF the buttons are the only things
    that add new content while the movie is playing, then the last
    thing added will have an index = numChildren-1,
    So if you want to remove the last movie before the new movie
    is added, then use removeChildAt(numChildren-1)
    Now, for the first time you use this, it will remove the last
    element on the stage, which you don't want, so you should probably
    have a variable that is set when any button is clicked and a
    conditional that checks it....
    var buttonClicked:Boolean = false; // set to true when a
    button is clicked
    in the handler:
    if(buttonClicked){
    removeChildAt(numChildren-1)
    buttonClicked = true;
    There are other ways of targeting in the event the movie was
    not the last thing added to the stage when another button gets
    clicked, such as assigning name to the movie or capturing which
    index it has when it is 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/

Maybe you are looking for

  • HP Pavilion p7-1221 Desktop PC only boots with 1 ram stick in after bios update

    Hello, I updated my BIOS because it was suggested by HP support.  My PC did not want to start afer that.  I did some reasearch and tried several things, like unplugging the power supply and taking out the CMOS battery.  I even referenced the beeping

  • When signing in the drop down menu lists lots of e-mail addresses how can I delete the ones no longer using this computer

    when I sign in to anything, face book, or a game etc and I click the box for inserting my e-mail address a drop down menu appears I cannot seem to delete any of the addresses on this list is there a way I can delete addresses from this list thus maki

  • Dynamic Global Host Name!!!

    Hello Everybody! I have Time Capsule 2TB, and i have an issue about it, which its how to connect to it via internet? i know that i must have mobileme account and to be added to advanced in the airport utility. then i have to setup the Dynamic Global

  • ODBC Driver update

    Hi I'm an Oracle novice, but have been fault-finding with an application at work, built in Powerbuilder, which seems to have issues with the ODBC driver that ships with Oracle 8.1.7 Basically, some date/time fields in the application are totally inco

  • SCCM 2012 Client agent not installing

    Hi, We have some client machines which has Client as "No" in the SCCM console. The ccmsetup.log file of these machines shows repeated entries like: Download Update: 56283664 out of 66797088 bytes transferred. ccmsetup.log file of another machine show