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

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

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

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

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

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

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

  • How to load and replace random swfs into same loader on stage?

    Hi...this is very simple, but, for some reason escapes me: using AS3 how can a swf load another swf to replace itself in the same loader on the stage, while simultaneously calling a randomizing function in the first frame of the main timeline, to randomize the next swf?
    At the end of each swf (called "koan_#.swf") there is the following old AS2 code...it was used to randomly select and then play a swf from koan array:
    _root.index++
    if(_root.index>_root.koan.length-1){
    _root.index=0;
    _root.koan.shuffle();
    _root.koan_loader_mc.loadMovie(_root.koan[_root.index]);
    This code on the first frame of the main timeline loads a random koan swf properly, but, after the koan plays I would like to load a new random koan swf.
    function shuffle(a:Array):Array {
    var len:Number = a.length-1;
    for (var ivar:Number = len; ivar>=0; ivar--) {
      var p:Number = Math.floor(Math.random()*(ivar+1));
      var t = a[ivar];
      a[ivar] = a[p];
      a[p] = t;
    return a;
    var index:uint = 0;
    var koan_loader:Loader = new Loader();
    var koan:Array =["swfs/koans/koan_1.swf","swfs/koans/koan_2.swf", "swfs/koans/koan_3.swf", "swfs/koans/koan_4.swf", "swfs/koans/koan_5.swf", "swfs/koans/koan_6.swf", "swfs/koans/koan_7.swf", "swfs/koans/koan_8.swf", "swfs/koans/koan_9.swf", "swfs/koans/koan_10.swf", "swfs/koans/koan_11.swf", "swfs/koans/koan_12.swf"];
    koan = shuffle(koan);
    koan_loader.load(new URLRequest(koan[index]));
    MovieClip(this).koan_loader_mc.addChild(koan_loader);
    Thank you very much.  I've tried multiple variations of updated AS2 code but am at my wits end. 

    Alright, the bloody forums won't attach the file for some reason, so here is the code:
    Copy and paste this code into a text file and save it as InterfaceEvent.as
    package {
         import flash.events.Event;
         public class InterfaceEvent extends Event {
              public static const KOAN_FINISHED:String = "koanFinished";
              public function InterfaceEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, index:int = -1, item:Object = null) {
                   super(type, bubbles, cancelable);
                   this.index = index;
                   this.item = item;
              public var index:int = -1;
              public var item:Object = null;
              override public function clone():Event {
                   return new InterfaceEvent(this.type, this.bubbles, this.cancelable, this.index, this.item);

  • 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

  • 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

  • How to load and resize a SWF in a MovieClip

    Hello.
    I want to download a SWF file and load it in a MovieClip.
    Once the
    downloaded SWF is loaded in the MoviClip I want to adjust its
    size to
    the parent MovieClip. I also want to restore the child clip
    to its
    original size and to drag it inside the parent MovieClip
    But it doesn't work:
    http://www.tel.uva.es/personales/jpozdom/moviClipLoaderWithPreload.swf
    http://www.tel.uva.es/personales/jpozdom/moviClipLoaderWithPreload.fla
    Could you help me?
    Thanks

    blemmo escribi�:
    > you can't change the properties before the clip is fully
    loaded. You already
    > have a listener for onLoadComplete, that's the right
    place to change the size.
    > Just place the restaurar() call before the play() call
    in that event.
    I tried it before submit the question but it doesn't work. If
    I call
    restaurar() just before the play() call in the onLoadComplete
    then I
    don't view the loaded clip in the window. You can test it if
    you want.
    I have fixed this using onClipEvent ( load ) in the
    contenedor_mc
    moviecliep. If I call restaurar() in this event it does work.
    You can test that in this example:
    http://www.tel.uva.es/personales/jpozdom/moviClipLoaderWithPreload.swf
    http://www.tel.uva.es/personales/jpozdom/moviClipLoaderWithPreload.fla
    Know I'm trying to make drag works...
    Thanks

  • How to share music on same computer with different accounts

    Hi -
    I just got a new IMAC and me and my girlfriend use it and have two different accounts on the computer. I am trying to figure out how she can listen to my music from my itunes account when she is logged into her account. I seem to be failing at the suggested home sharing options that apple reccomends? is there a way? does she need to import all my songs into her account and recreate her own playlists that way?
    thanks for any and all help
    j

    Ok, so the iTunes music folder holds all the music. I copy or drag my iTunes folder and my Daughters iTunes folder from our separate user accounts to the shared music folder. Then open iTunes and steer my and my Daughters iTunes Music folder location to the same place.
    If she downloads new music I would have to open iTunes under my user account. Go file/add folder to library/ locate the new music on the shared music folder and that would bring something into my library file so I could see the new music on my iTunes.
    I guess what I started out to do was save memory space on my computer. Does all this do that?
    If it doesn’t I really don’t care anymore as long as I can copy her new music to my iTunes and vise versa.
    Thanks for the help
    Mainer

  • How to upgrade AND move between platforms with different Endians...?

    Hi, all,
    I have two databases - one of 500Gb and one of 50Gb - that are currently running on 10.2.0.4 on AIX 64-bit. They are Production systems.
    I have to move them to a brand new Linux (RHEL 5.6 - 64-bit) server that will be running 11.2.0.2.
    For test, I'm OK with this being done with Data Pump. But for the eventual move to 'New Prod', this will result in hours' worth of downtime and it's a business-critical system, so I'm trying to mitigate that as much as I can.
    I was, naively, hoping to use RMAN to both move the databases from one box to the other, but also to upgrade them. I figure I would do the following (as per Metalink 369644.1) as I have a Recovery Catalog, etc, etc:
    Install the binaries on the New Prod server
    Connect to the RCAT and restore the database and recovery to a PiT
    Manually upgrade the database by putting the DB into STARTUP UPGRADE and running the catupgrd.sql
    Unfortunately, I didn't realise the Endian was different between AIX and RHEL (as per 1079563.1). Oops.
    It doesn't look like I'll be able to use Transportable Tablespaces (as per 243304.1) either without first having to migrate the data across as a 10g DB and then upgrading.
    So my options appear to be:
    a) Data Pump and suck the outage up
    b) Move the data using Transportable Tablespaces to 10.2.0.4 and then upgrade to 11.2.0.2.
    Are there any other options? I have hopes that a logical standby would work in this instance a la rolling upgrade, but suspect that the different O/S AND the different Endian would scupper that idea...
    Mark

    Perhaps, I have more experience using concurrent exports/imports using the traditional exp/imp utility than using the parallel option on expdp/impdp. One thing you can do with exp/imp that you cannot do with expdp/impdp is export into a named pipe, start a remove copy of the named pipe to the new server, and then start importing from the named pipe on the new server so that you are importing while still exporting the same objects. We use tables= exports when we did this back when the tables= parameter could only handle 99 tables. We had a separate export for every large table and then a set of exports for 99 tables for each of the other tasks ran 6 to 12 concurrent processes.
    One thing to look at is historic data. Potentially some tables can be moved in advance of the majority of the application objects and replaced with synonym to remote objects.
    Truely static tables could also potentially be moved in advance even if only a day or two before to reduce the number of objects to be moved.
    Build the new database in noarchive log mode to save some processing and switch it over and immediately back it up when you migrate.
    And Yes, if the two platforms appear in the view name I gave you then you can use transportable tablespaces with the rman conversion step. Instructions for using rman to do the conversion are in the rman manual.
    HTH -- Mark D Powell --

  • Display/load and Unload SWF in flex

    hi friends
    i wnat to disply external SWF file into flex but without using SWFLOader(it's make lot's of problem) nad i also Embed that SWF
    this is code
    [Embed(source="1.swf")]
    private var loadswf:Class;
    private function load():void{
    var symb:MovieClip = new loadswf() as MovieClip;
    this.addChild(symb);
    it's give me error....
    TypeError: Error #1034: Type Coercion failed: cannot convert demos_loadswf@39ab3c1 to mx.core.IUIComponent.
    please help to resolve this error or give me suggestion to simple Disply/Load and Unload Embed SWF file in flex

    thnx Flex harUI
    i added UI componentes now my full code is like..
            import mx.controls.Image;    
            import mx.controls.Alert;
            [Embed(source = "1.swf")]
            public var SWF:Class;
            [Embed(source = "2.swf")]
            public var SWF2:Class;
            private var mc:MovieClip;
            private var img:Image;
            protected function checkBtn_clickHandler(event:MouseEvent):void
                clear();
                img = new Image();
                img.width=Number("700");
                img.height=Number("700");
                mc = new MovieClip();
                mc = MovieClip(new SWF());
                img.source = mc;
                vBox0.addChild(img);
            protected function critcalBtn_clickHandler(event:MouseEvent):void
                clear();
                img = new Image();
                img.width=Number("700");
                img.height=Number("700");
                mc = new MovieClip();
                mc = MovieClip(new SWF2());
                img.source = mc;
                vBox0.addChild(img);
            protected function clear():void
                try{
                    if(mc!=null){
                        flash.media.SoundMixer.stopAll();
                        img.source="";
                        img.source=null;
                        mc=null;
                        vBox0.removeChild(DisplayObject(img));
                        vBox0.removeAllElements();
                        vBox0.removeAllChildren();
                }catch(e:Error){
                    Alert.show(e + " ----::---- ");
    <mx:Canvas id="vBox0" width="700" height="700" ></mx:Canvas>
    <mx:HBox >
            <mx:Button id="checkBtn" label="first" click="checkBtn_clickHandler(event)"/>
            <mx:Button id="critcalBtn" label="second" click="critcalBtn_clickHandler(event)"/>
    </mx:HBox>
    now my error gone!!! but one problem is there when i unload my first SWF and load second SWF(on button click), my first SWF sound are still play in Background, i cn't unstand Y this will happen coz i already remove all object and child from my Canvas.
    any help on this....

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

  • 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 do I copy purchases between 2 itunes libraries on the same computer with different log ins and separate apple user ids?

    How do I copy purchases between 2 itunes libraries on the same computer with different log ins and separate apple user ids?

    Load the library which doesn't contain the songs and drag them into the open iTunes application window. If you need to move them between different computer user accounts, put them into /Users/Shared/.
    (74502)

Maybe you are looking for

  • Retrive Business Partners related to the filters of an Attribute set

    Hi SAP Gurus, I hv a requirement to get Business Partners related to the filters of an Attribute set. I hv used a FM 'CRM_MKTTG_SAL_SEARCH_DB' to get the GUID of the attribute list. If the GUID is passed to another FM 'CRM_MKTTG_SAL_READ' we can get

  • What is the right macbook for me?

    So I convinced my mom to get a macbook, but the next problem is what macbook is right for me? I will use it for school work : I will use it for: - Word proccessing - portability - slideshows - programming in xcode and in Java - Gaming - Music - Devel

  • Hi bought an Ipod and a friend put music on it for me but will I lose the music if I sync it with my own computer?

    A friend has put music on my IPOD but now I would like to add more from my own PC. Will I lose all the original music if I erase and sync?

  • Charge should be applicable only three times

    Dear all, I have a scenario, where I need some advice. A subcontracting scenario. Print Order is sent to a subcontractor for printing. Printing requires Plate, and subcontracting Vendor provides the plate by himself. However, the plate charges are ap

  • [svn] 3174: integrate:

    Revision: 3174 Author: [email protected] Date: 2008-09-10 18:00:03 -0700 (Wed, 10 Sep 2008) Log Message: integrate: -vellum build 169 -player 10 build 10.0.0.602 patched file TextView.as to work with vellum API change Modified Paths: flex/sdk/trunk/f