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

Similar Messages

  • 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

  • Help with load and unload swf file.

    hello, just now i try, to  load my file using the code snippet 'load and unload' i manage to load the next file succesfully but why my recent file still appear in the background? how do i make it gone?

    When you load another SWF you're loading it 'inside' the current SWF but it appears that you want to replace the current SWF entirely with the new SWF, is that correct?
    If so you should make what's usually known as a 'stub' or a loader. Make an empty project that merely acts as a loader. It should load your first SWF and when you press a button on that first SWF to load a second SWF, it should signal the 'stub' it's loaded inside to unload the first SWF and then load the second.
    e.g. a stub.swf (just coding out of memory, not error checked, just to give a general idea):
    // make a new loader to do all the loading of SWFs
    var loader:Loader = new Loader();
    // and display
    addChild(loader);
    // a function to load a SWF into the loader (replacing any existing SWF)
    function loadSWF(path:String):void
         // assure path is defined or do nothing
         if (!path) return;
         // load requested SWF
         loader.load(new URLRequest(path));    
    // load initial SWF
    loadSWF('/path/to/1.swf');
    For your 1.swf to use the function, you're currently inside the .content property of a Loader so I believe you can just run a command like: Object(this.parent.parent).loadSWF('/path/to/2.swf');
    This example obviously lacks any error checking or transitions but you can add those and season to taste.

  • How to load and unload same SWF with different xmlFilePath?

    I have a slideshow on my homepage and try to load and unload same instance with different xmlFilePath based on language on the same page.
    var flashvars = {
            xmlFilePath: escape("http://www.bodto.com.tr/kik.aspx"),
            xmlFileType: "OPML",
            lang: swfobject.getQueryParamValue("lang")    
            //initialURL: escape(document.location)   
          var params = {
            bgcolor: "#000000",  
            allowfullscreen: "true",
            wmode:"transparent",
            allowScriptAccess: "always"
          var attributes = {}
              swfobject.embedSWF("/swf/slideshowpro.swf", "flashcontent", "550", "400", "10.0.0", false, flashvars, params, attributes);
    Actionscript3
    var langPath = root.LoaderInfo.parameters["xmlFilePath"]+root.LoaderInfo.parameters["lang"];
    my_ssp.xmlFilePath = langPath;
    var fileType = root.LoaderInfo.parameters["xmlFileType"];
    my_ssp.xmlFileType = fileType;
    Based on above informations, how could I achieve it?

    Suddenly that code in the following gives me some error
    var langPath = root.LoaderInfo.parameters["xmlFilePath"]+root.LoaderInfo.parameters["lang"];
    my_ssp.xmlFilePath = langPath;
    var fileType = root.LoaderInfo.parameters["xmlFileType"];
    my_ssp.xmlFileType = fileType;
    Access of possibly undefined property LoaderInfo through a reference with static type flash.display:DisplayObject.
    The only code snippet works is
    var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
    for (var param in paramObj) {
       if (param == "xmlFilePath") {
          my_ssp.xmlFilePath = paramObj[param];
       if (param == "xmlFileType") {
          my_ssp.xmlFileType = paramObj[param];

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

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

  • Loading and Unloading of swf files in SWF Loader

    Hi all,
    I have a doubt reg. SWF Loader.
    I have created two mxml files A & B.
    A. local.mxml
    B. SwfSample.mxml
    i have two labels and a button in A file and i have set values to those labels and have a method to handle the click event of the button. In B file i have loaded this A file and accessed the labels and methods using SystemManager Component and changed the values of the A file's label and accessed data from A file to B file.
    Here comes the problem,
    I have two buttons named LoadAgain and Unload
    When i click the Unload button, the SWF Loader unloads its content by the method i handled for  the Unload button, after that i have clicked on the LoadAgain button to load the same content of A's mxml to the SWF Loader, it loads succesfully,but i was not able to access its Label or Method from the B mxml. Please help me to solve the issue.
    local.mxml
    <?xml version="1.0" encoding="utf-8"?><mx:Application 
    xmlns:mx=http://www.adobe.com/2006/mxml layout="absolute">
    <mx:Script>
        <![CDATA[
    Bindable]
        public var varOne:String = "This is a public variable";
        public function setVarOne(newText:String):void
              varOne = newText;
        ]]>
    </mx:Script>
    <mx:Label id="lblOne" text="I am here" x="28" y="88"/>
    <mx:Label text="{varOne}" x="166" y="88"/>
    <mx:Button label="Nested Button" click="setVarOne('Nested Button Pressed');" x="28" y="114"/>
    SwfSample.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application 
    xmlns:mx=http://www.adobe.com/2006/mxml layout="absolute">
        <mx:Script>
        <![CDATA[
              import mx.controls.Alert;  
              import mx.managers.SystemManager;  
              import mx.controls.Label; 
    Bindable]
              public var loadedSM:SystemManager;
              private function initNestedAppProps():void
                  loadedSM = SystemManager(myLoader.content);
              public function updateLabel():void
                  lbl.text = loadedSM.application[
    "lblOne"].text;
              public function updateNestedLabels():void
                  loadedSM.application[
    "lblOne"].text = "I was just updated" ;
                  loadedSM.application[
    "varOne"] = "I was just updated";
              public function updateNestedVarOne():void
                   local(loadedSM.application).setVarOne(
    "Updated varOne");
              public function unload():void
                   myLoader.content.loaderInfo.loader.unload();
              public function loadAgain():void
                   myLoader.load(
    "../bin-debug/local.swf");
            ]]>
         </mx:Script>
    <mx:Label id="lbl" x="72" y="47"/>
    <mx:SWFLoader id="myLoader" width="438" source="../bin-debug/local.swf" creationComplete="initNestedAppProps();" y="73" height="238" x="72" alpha="1.0"/>
    <mx:Button label="Update Label Control in Outer Application" click="updateLabel();" x="72" y="319"/>
    <mx:Button label="Update Nested Controls" click="updateNestedLabels();" x="72" y="349"/>
    <mx:Button label="Update Nested varOne" click="updateNestedVarOne();" x="72" y="379"/>
    <mx:Button label="Unload" click="unload();" x="72" y="409"/>
    <mx:Button label="Load Again" click="loadAgain();" x="72" y="439"/>
    </mx:Application>
    Thanks & regards,
    Sathish.K

    creationComplete only fires once when the SWFLoader is created.  Therefore you never reset your variables to point to the new sub-app.  On a slow network, creationComplete may fire before the sub-app loads.  It is best to use the COMPLETE event.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • Chrome (Windows NT 6.1 6.2) users reporting problems with loading and mouseevents - any insights?

    For several years now, I have created simple studies (I do psychological stuff) to run online, recruiting participants through Amazon Mechanical Turk (AMT). I have had no problems until recently (last 6 to 9 months). Now, some AMT users are reporting problems with stimuli loading or buttons not responding immediately when clicked (e.g., advancing to a new screen). What is common amongst all the users experiencing problems is that they use Chrome, and they also tend to be Windows NT 6.1 or 6.2 users running Flash Player 12.0. But not a single Firefox, Safari, or MSE user has ever reported an issue. I'm just looking for help in troubleshooting this problem. Again, the studies I run are incredibly simple (e.g., no videos being loaded from server, etc.), mostly word presentation where I record time and x,y coordinates of mouse movements as they respond to questions. Would attempting to publish for another target version of Flash Player help? The default setting is to publish the .swf and .html wrapper for Flash Player version 11.7. Any ideas? I also use version 13.0.1 of Flash Professional CC to create my studies if it helps. 

    This is helpful. Thanks. So it would be to my advantage to play around with something like SWFObject 2?
    http://www.adobe.com/mena_fr/devnet/flashplayer/articles/swfobject.html
    Or is there something else you would recommend?
    What I've been doing is a far cry from actual web development, but quite interested in learning more. This swfobject seems to get at what you are suggesting (I think). 

  • A problem with loading xml from external URl in flex

    So I have a server running (localhost) and I wrote an  application to request information from another website and return data  (xml). The application worked fine when I was using the flash builder  and just testing it on my machine (not using the localhost), when I  started using the server with the same exact code, it requested the  crossdomain.xml file to assure that I can request information from that  site, so I added the file and the file is right, the script gets it  (according to firebug), however, it is not getting the xml information  it should get, it just gets stuck with (waiting information from  blah.com) at the bottom.
    Is there a way to solve the problem?
    (I turned my firewall off and it didn't work either)

    Yeah I did test the URL and everything is going fine, the information is not returned to the flex application that's all.
    I am testing with FireBug and it is telling me that the request is in fact sent to the site but I don't think anything (either than the crossdomain function) is returned.
    Thanks for the help, I am really not sure what is going on.

  • Problem with T61 and DVI External Monitor (via Advanced Mini-Dock)

    Ever since I upgraded to Vista SP1 on my ThinkPad T61 (with an Intel integrated 965 series graphics card), I've been having problems when I try to use an external monitor via the DVI port in my Advanced Mini-dock.  I'm curious if other people have experienced this problem.
    The problems surfaces when I first boot up, or sometimes after my ThinkPad has been running for awhile (particularly when I do something graphics related, such as right-clicking to open display properties).  The picture starts to flicker (or disappear and reappear, like the screen does when changing graphics resolutions).  I also hear the "ba-bum" sound that you hear when disconnecting a piece of hardware, followed by the "bum-ba" reconnection sound - these two sounds happen repeatedly (sometimes as fast as once per second).  If I don't do anything, sometimes I'll get a bluescreen.
    Not long ago, I found a fix of sorts: to stop the flickering/reconnecting, I just open Task Manager and stop the process called "igfxpers" (an Intel driver problem).  The problem always disappears after I do this, although I have to remember to do it every time I reboot or else the problem comes back.  So it's not an ideal fix.
    This problem doesn't happen when I connect an external monitor using the analog VGA port, or when I'm just using the notebook LCD.  It's limited to just the DVI connection.  I've tried two different digital monitors (one LG, the other BenQ) as well as two DVI cables - the problem is still the same.  So it seems like a driver problem of some sort - unfortunately, the Intel drivers haven't been updated since last February.
    I should also note that I've tried reinstalling my OS two or three times, and the problem always comes back.  Has anyone else had this problem, and is a fix on the way?

    Error Message:
    Input signal out of range. Translation:
    You will see this on an otherwise blank screen. Assuming that the data cable is plugged in correctly, the video card is feeding the monitor a signal stream in excess of what the monitor can accommodate. The two main causes for this are that the user has set either the resolution or the vertical frequency rate too high. For example, you might set a new graphics card to display at 1,280 x 1,024, but if the monitor is only capable of 1,024 x 768 resolution, you’ll get a Sync Out of Range error. This is especially common in 14-inch monitors.
    Solution:
    Because you obviously can’t make settings changes from within regular Windows, you’ll need to reboot into Windows Safe Mode. When you restart the system, there is a point during boot up when the system switches from reporting diagnostics and detected components to loading Windows. This point is usually accompanied by a beep and the screen going black. Just before this point, you want to start repeatedly pressing the F8 key. This should bring up a menu of Windows boot options. The one you want to pick is Safe Mode.
    From Safe Mode right-click the Desktop and select Properties. Go to the Settings tab and use the slider to drop your resolution a notch or two. Reboot and let Windows try to go into Normal mode. If this still doesn’t work, go back into Safe Mode and get to the Settings tab of Display Properties. Click the Advanced button, go to the Monitor tab, and check your refresh rate. The lowest advisable rate is usually 60Hz, although this works better for LCDs (liquid-crystal displays) than CRTs (cathode ray tubes). Apply the change and reboot.

  • ASA5505 Upgrade to 9.1.5 from 8.4.1 - problem with nat and accessing external host

    When running on 8.4 i had a working config with the following scenario.
    I have 2 interfaces configured as the outside interface.
    One is connected to my internet connection
    The other one is connected to a host that has a public ip.
    The public host can access internet and also a PAT port on an internal host.
    But after the upgrade the internal hosts can't access the external host but everything else on internet 
    packet-tracer input inside tcp 10.x.x.11 1024 x.x.x.89 22
    Phase: 1
    Type: ACCESS-LIST
    Subtype: 
    Result: ALLOW
    Config:
    Implicit Rule
    Additional Information:
    MAC Access list
    Phase: 2
    Type: ROUTE-LOOKUP
    Subtype: input
    Result: ALLOW
    Config:
    Additional Information:
    in   x.x.x.0    255.255.240.0   outside
    Result:
    input-interface: inside
    input-status: up
    input-line-status: up
    output-interface: outside
    output-status: up
    output-line-status: up
    Action: drop  
    Drop-reason: (nat-no-xlate-to-pat-pool) Connection to PAT address without pre-existing xlate
    If i add 1 to the destination ip:
    packet-tracer input inside tcp 10.x.x.11 1024 x.x.x.90 22
    Phase: 1
    Type: ROUTE-LOOKUP
    Subtype: input
    Result: ALLOW
    Config:
    Additional Information:
    in   x.x.x.0    255.255.240.0   outside
    Phase: 2
    Type: ACCESS-LIST
    Subtype: log
    Result: ALLOW
    Config:
    access-group inside_access_in in interface inside
    access-list inside_access_in extended permit ip any4 any4 
    Additional Information:
    Phase: 3
    Type: NAT
    Subtype: 
    Result: ALLOW
    Config:
    nat (inside,outside) source dynamic any interface
    Additional Information:
    Dynamic translate 10.x.x.11/1024 to x.x.x.80/1024
    Phase: 4
    Type: NAT
    Subtype: per-session
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 5
    Type: IP-OPTIONS
    Subtype: 
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 6
    Type: NAT
    Subtype: rpf-check
    Result: ALLOW
    Config:
    nat (inside,outside) source dynamic any interface
    Additional Information:
    Phase: 7      
    Type: USER-STATISTICS
    Subtype: user-statistics
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 8
    Type: NAT
    Subtype: per-session
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 9
    Type: IP-OPTIONS
    Subtype: 
    Result: ALLOW
    Config:
    Additional Information:
    Phase: 10
    Type: USER-STATISTICS
    Subtype: user-statistics
    Result: ALLOW 
    Config:
    Additional Information:
    Phase: 11
    Type: FLOW-CREATION
    Subtype: 
    Result: ALLOW
    Config:
    Additional Information:
    New flow created with id 98586, packet dispatched to next module
    Result:
    input-interface: inside
    input-status: up
    input-line-status: up
    output-interface: outside
    output-status: up
    output-line-status: up
    Action: allow
    Nat rules:
    nat (inside,outside) source static IPv6_HOST interface service https https
    nat (inside,outside) source static IPv6_HOST interface service http http
    nat (inside,outside) source static IPv6_HOST interface service ssh ssh
    nat (inside,outside) source static INTERNAL interface destination static EXTERNAL EXTERNAL service apcupsd apcupsd
    nat (inside,outside) source static IPv6_HOST interface destination static IPv6_POP IPv6_POP
    nat (inside,outside) source dynamic any interface
    The EXTERNAL is the host that is connected to an outside interface and that NAT rule works ok.
    I can ping the EXTERNAL host from the ASA but not from the internal network.
    Any ideas would be appreciated.

    Hmmm, by adding the following i got it working:
    nat (inside,outside) source static IPv6_HOST interface service https https
    nat (inside,outside) source static IPv6_HOST interface service http http
    nat (inside,outside) source static IPv6_HOST interface service ssh ssh
    nat (inside,outside) source static INTERNAL interface destination static EXTERNAL EXTERNAL service apcupsd apcupsd
    nat (inside,outside) source static IPv6_HOST interface destination static IPv6_POP IPv6_POP
    nat (inside,outside) source dynamic inside interface destination static EXTERNAL EXTERNAL
    nat (inside,outside) source dynamic any interface
    It is a bit complicated though since the EXTERNAL host get it's address via DHCP and so does the ASA.

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

  • Best practices for using .load() and .unload() in regards to memory usage...

    Hi,
    I'm struggling to understand this, so I'm hoping someone can explain how to further enhance the functionality of my simple unload function, or maybe just point out some best practices in unloading external content.
    The scenario is that I'm loading and unloading external swfs into my movie(many, many times over) In order to load my external content, I am doing the following:
    Declare global loader:
    var assetLdr:Loader = new Loader();
    Load the content using this function:
    function loadAsset(evt:String):void{
    var assetName:String = evt;
    if (assetName != null){
      assetLdr = new Loader();
      var assetURL:String = assetName;
      var assetURLReq:URLRequest = new URLRequest(assetURL);
      assetLdr.load(assetURLReq);
      assetLdr.contentLoaderInfo.addEventListener( Event.INIT , loaded)
      assetLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayAssetLoaderProgress);
      function loaded(event:Event):void {
       var targetLoader:Loader = Loader(event.target.loader);
       assetWindow.addChild(targetLoader);
    Unload the content using this function:
    function unloadAsset(evt:Loader) {
    trace("UNLOADED!");
    evt.unload();
    Do the unload by calling the function via:
    unloadAsset(assetLdr)
    This all seems to work pretty well, but at the same time I am suspicious that the content is not truly unloaded, and some reminents of my previously loaded content is still consuming memory. Per my load and unload function, can anyone suggest any tips, tricks or pointers on what to add to my unload function to reallocate the consumed memory better than how I'm doing it right now, or how to make this function more efficient at clearing the memory?
    Thanks,
    ~Chipleh

    Since you use a single variable for loader, from GC standpoint the only thing you can add is unloadAndStop().
    Besides that, your code has several inefficiencies.
    First, you add listeners AFTER you call load() method. Given asynchronous character of loading process, especially on the web, you should always call load() AFTER all the listeners are added, otherwise you subject yourself to unpredictable results and bud that are difficult to find.
    Second, nested function are evil. Try to NEVER use nested functions. Nested functions may be easily the cause for memory management problems.
    Third, your should strive to name variables in a manner that your code is readable. For whatever reason you name functions parameters evt although a better way to would be to name them to have something that is  descriptive of a parameter.
    And, please, when you post the code, indent it so that other people have easier time to go through it.
    With that said, your code should look something like that:
    function loadAsset(assetName:String):void{
         if (assetName) {
              assetLdr = new Loader();
              assetLdr.contentLoaderInfo.addEventListener(Event.INIT , loaded);
              assetLdr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, displayAssetLoaderProgress);
              // load() method MUST BE CALLED AFTER listeners are added
              assetLdr.load(new URLRequest(assetURL));
    // function should be outside of other function.
    function loaded(e:Event):void {
         var targetLoader:Loader = Loader(event.target.loader);
         assetWindow.addChild(targetLoader);
    function unloadAsset(loader:Loader) {
         trace("UNLOADED!");
         loader.unload();
         loader.unloadAndStop();

  • How to load and unload Multiple External SWF

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

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

Maybe you are looking for