Unload SWF.

I recieved some help earlier with actionscript 3.0 and buttons. I wanted my buttons to load in a swf file into the main flash document when clicked. I can't seem to figure out how to get multiple swfs files loaded into the flash document. I also need the swf files to unload when an diffrenent buttons is clicked.
var myMenuArray: URLRequest = new URLRequesr["we.swf","port.swf"]:
for each (var btn in myMenuArray){
    btn.addEventListener(MouseEvent.CLICK, onbtnClick);
function onbtnClick (event:MouseEvent):void{
    pages.gotoAndStop(event.target.name);
var ldr:Loader = new Loader();
we_btn.addEventListener(MouseEvent.CLICK, weClick);
function weClick (event:MouseEvent) {
ldr.load(urlReq);
addChild(ldr)

Ok, it has taken me sometime (roughly 4 hours) to load the swf with each button. I created a movieclip with the instance name of ldr to match the loader code in action script. When the movieclip has an intance name of ldr I recieve this error
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@1db47061 to flash.display.Loader.
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at index_fla::MainTimeline()
However, if I don't use the moviclip the swf files will be placed in the upper left hand corner of the stage. Why is this?
this is the link to my website I don't have the current code below updated to the server yet(http://studio-5-design.net/index.html).
A critique of my site will also help me. I am an architecture student and I am creating a site to display my school projects along with a portfolio
modified code
var ldr:Loader = new Loader();
////////////Home Button///////////////////////////////////////
var homeReq:URLRequest=new URLRequest("_swf/home.swf");
home_btn.addEventListener(MouseEvent.CLICK, homeClick);
function homeClick(event:MouseEvent) {
    ldr.load(homeReq);
    addChild(ldr);
////////////We Are Button///////////////////
var weReq:URLRequest=new URLRequest("_swf/we.swf");
we_btn.addEventListener(MouseEvent.CLICK, weClick);
function weClick(event:MouseEvent) {
    ldr.load(weReq);
    addChild(ldr);
////////////Portfolio Button////////////////////////////////////////////////
var portReq:URLRequest=new URLRequest("_swf/port.swf");
port_btn.addEventListener(MouseEvent.CLICK, portClick);
function portClick(event:MouseEvent) {
    ldr.load(portReq);
    addChild(ldr);
/////////////Reflections Button/////////////////////////////////////////////
var reflReq:URLRequest=new URLRequest("_swf/reflection.swf");
reflec_btn.addEventListener(MouseEvent.CLICK, reflClick);
function reflClick(event:MouseEvent) {
    ldr.load(reflReq);
    addChild(ldr);

Similar Messages

  • Loading and unloading swf

    I am making a site and I want each button to load an swf,
    which would be the content of each page. When I click on each
    button the swf will load, however, the old swf will not go away.
    how does one do this. Thanks.

    It looks like you are adding the newly loaded swf, but not
    removing the old one. So, maybe this change would help:
    function about_CLICK(myevent:MouseEvent):void{
    var loadMain:Loader = new Loader();
    loadMain.load(new URLRequest("clip0.swf"));
    // if there is a child on the display list remove it
    if (getChildAt(0) !=null) removeChildAt(0);
    stage.addChild(loadMain);
    I should mention, however, that there is a bug in Flash 9
    related to unloading swfs:
    http://www.gskinner.com/blog/archives/2008/04/failure_to_unlo.html
    However, I don't think this is affecting your visible
    behavior.

  • Loader, Unload SWF and Warning: Ignoring 'secure' attribute........

    Hey all
    I was just simply trying to load one swf into another.  in my document class I have the following line of code in my constructor.
    var loadBoard:LoadBoard = new LoadBoard("Directory.swf");
    in my LoadBoard class:
    package com.myproject
         import flash.display.Loader;
         import flash.display.MovieClip;
         import flash.net.URLRequest;
         public class LoadBoard extends MovieClip
              public function LoadBoard(nameOfBoard:String)
                   var boardLoader:Loader = new Loader();
                   addChild(boardLoader);
                   boardLoader.load(new URLRequest(nameOfBoard));
                   trace("swf should be loaded");
    In my console I get the following when I debug"
    [SWF] U:\fullPath\Directory.swf - 69,058 bytes after decompression
    [SWF] U:\fullPath\Directory.swf - 2,067 bytes after decompression
    [SWF] U:\fullPath\Directory.swf - 322,606 bytes after decompression
    [SWF] U:\fullPath\Directory.swf - 112,558 bytes after decompression
    [Unload SWF] U:\fullPath\Directory.swf
    Warning: Ignoring 'secure' attribute in policy file from http://fpdownload.adobe.com/pub/swz/crossdomain.xml.  The 'secure' attribute is only permitted in HTTPS and socket policy files.  See http://www.adobe.com/go/strict_policy_files for details.
    Not sure why I am getting this warning, when I googled it, the erro has to do with trying to load a file from another domain. My Directory.swf file is in the same location as my main swf, the bin-debug folder.  Also the Directory.swf does not seem to load into my main swf as I don't see it show up in the flash player when i run my app.   I am also a little confused on the [Unload SWF], I am not doing anything to tell it to Unload my swf.
    I am using FB to do all my coding and debugging if that matters.
    Does anyone have any ideas.
    thanks,

    Apparently I was, so I changed it to classic text in my Directory.fla and that seemed to remove the weird error.  However it seem that my swf is still not loading.  any Ideas why that might be?
    [EDIT]  Ok, my Directory swf is defenatly loading. but not showing up in the display list. I updated my LoadBoard to the following.
    package com.aces
         import flash.display.Loader;
         import flash.display.MovieClip;
         import flash.events.Event;
         import flash.net.URLRequest;
         public class LoadBoard extends MovieClip
              public function LoadBoard(nameOfBoard:String)
                   var boardLoader:Loader = new Loader();
                   boardLoader.load(new URLRequest(nameOfBoard));
                   boardLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
              public function finishLoading(loadEvent:Event):void
                   addChild(loadEvent.currentTarget.content);
                   trace("swf should be loaded");
    any Ideas?
    Thanks,

  • SWFLoader.unloadAndStop() - does it unload swf and release memory?

    Hi all,
    Do SWFLoader FP10 unloadAndStop() and GC really unload swf?
    I have simpliest test case possible when parent app creates new SWFLoader, loads sub app and then unloads it.
    Every time when it does it I see memory grows. The sub app is tiny:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Label id="idLabel" color="blue" text="This is embedded application."/>   
    </mx:Application>
    The parent application is also simple
    public function loadSwf(name:String):void
      loader.addEventListener(Event.COMPLETE, completeHandle, false, 0, true);   
      loader.showBusyCursor = true;
      loader.scaleContent = true;
      loader.source=name;     // name is subappswf.swf the
      loader.load();
    private function completeHandle(event:Event):void
      loader.removeEventListener(Event.COMPLETE, completeHandle);
      loader.unloadAndStop(true);
    Profiler shows decent Peak Memory and even Cumulative Memory does not seem horrible. There are no objects hanging in sub-application except SystemManager. But Google Chrom Task Manager shows the real picture:  Shockwave Flash memory grows and as soon it reaches threshold ~0.5 GB, application becomes unresponsive and eventually FP crashes.
    What else should be done to free up memory?
    Regards,
    Ilya

    This is iInteresting...
    /*** Unloads an image or SWF file. After this method returns the
    * <code>source</code> property will be null. This is only supported
    * if the host Flash Player is version 10 or greater. If the host Flash
    * Player is less than version 10, then this method will unload the
    * content the same way as if <code>source</code> was set to null.
    * This method attempts to unload SWF files by removing references to
    * EventDispatcher, NetConnection, Timer, Sound, or Video objects of the
    * child SWF file. As a result, the following occurs for the child SWF file
    * and the child SWF file's display list:
    * <ul>
    * <li>Sounds are stopped.</li>
    * <li>Stage event listeners are removed.</li>
    * <li>Event listeners for <code>enterFrame</code>,
    * <code>frameConstructed</code>, <code>exitFrame</code>,
    * <code>activate</code> and <code>deactivate</code> are removed.</li>
    * <li>Timers are stopped.</li>
    * <li>Camera and Microphone instances are detached</li>
    * <li>Movie clips are stopped.</li>
    * </ul>
    * @param invokeGarbageCollector Provides a hint to the garbage collector to run
    * on the child SWF objects (<code>true</code>) or not (<code>false</code>).
    * If you are unloading many objects asynchronously, setting the
    * <code>gc</code> parameter to <code>false</code> might improve application
    * performance. However, if the parameter is set to <code>false</code>, media
    * and display objects of the child SWF file might persist in memory after
    * the child SWF has been unloaded.
    public function unloadAndStop(invokeGarbageCollector:Boolean = true):void
    useUnloadAndStop =
    true;unloadAndStopGC = invokeGarbageCollector;
    source =
    null; // this will cause an unload unless autoload is true
    if (!autoLoad)load(
    null);}
    It means that if autoload is true (default) unload will not happen and sub-app
    will persist in memory.
    Regards,
    Ilya

  • Redirect [SWF] and [Unload SWF] trace?

    Hi all!
    I was wondering if there is a way to redirect or disable
    [SWF] and [Unload SWF] based messages when working with external
    SWFS.
    Ideally I would like to redirect trace statements, but I
    doubt that's possible.
    Thanks!

    I would like to add a question to this topic, but instead of describing it, I would like to refer to this forum, where it was described very good: http://www.gotoandlearnforum.com/viewtopic.php?f=33&t=28730
    In short:
    When the loader object is only referenced by a local variable within a method and there's no other reference to the loader, other than the EventListener, the loaded SWF file is being sporadically unloaded (by the GC perhaps) before I am able to access the loader.content! That's kind of a bug, I guess and not acceptable!
    So any help would be much appreciated!
    Regards,
    Matthias

  • [Unload SWF] - Automatically unloading a swf while loading - GC issue?

    Hi, I am trying to load a few style SWFs at runtime using the StyleManager.loadStyleDeclarations. There are more than 4 style SWFs and I load them through a for loop and add the IEventDispatcher to an array as a reference.. The files seem to load properly. But some times, some of the style SWFs are automatically unloaded . I see the [unload SWF] in the log... I am not sure how to avoid the files being GCed at the time of loading... Also it seems like they are being loaded/ decompressed twice. Please see the log below...
    [SWF] /Flex/com/../styles/Common.swf - 45,421 bytes after decompression
    [SWF] /Flex/com/../styles/StyleSkin.swf - 253,886 bytes after decompression
    [SWF] /Flex/com/../styles/StyleSkin_Fonts.swf - 440,292 bytes after decompression
    [SWF] /Flex/com/../styles/ StyleSkin _Assets.swf - 189,281 bytes after decompression
    [SWF] /Flex/com/../styles/ StyleSkin _Assets.swf - 1,153,335 bytes after decompression
    [SWF] /Flex/com/../styles/ Common.swf - 1,153,335 bytes after decompression
    [SWF] /Flex/com/../styles/ StyleSkin _Fonts.swf - 1,153,335 bytes after decompression
    [SWF] /Flex/com/../styles/ StyleSkin.swf - 1,153,335 bytes after decompression
    [Unload SWF] /Flex/com/marketlinx/mls/client/ui/styles/StyleSkin_Assets.swf
    [Unload SWF] /Flex/com/marketlinx/mls/client/ui/styles/Common.swf
    [Unload SWF] /Flex/com/marketlinx/mls/client/ui/styles/StyleSkin _Fonts.swf
    How can avoid the files being GCed. is it because I  re use a single Loader (loadStyleDeclaration) to load multiple files?

    Both the copies go away.. and I don't load them twice , only once through a loop and when i debug and see the for loop below is executed only once... Am I not doing it the right way? . I am failry new to Flex and I couldn't find why Flex loads it twice
    This is how try to load them in the application...
    for   (var index:uint = 0; index < styleSheetFiles.length; index++){
    styleSheetsLoaded[index] =
    false; 
    // Load the stylesheet files
    var styleSheetFileFullPath:String = STYLESHEET_FILE_BASE_PATH + (styleSheetFiles[index] as String);eventDispatchers[index] = StyleManager.loadStyleDeclarations(styleSheetFileFullPath)
    as IEventDispatcher; 
    trace("loading: index" + index + " file:" + styleSheetFileFullPath); 
    // It doesn't matter whether the result is complete or error
    (eventDispatchers[index]
    as IEventDispatcher).addEventListener(StyleEvent.COMPLETE, styleSheetFileLoaded);(eventDispatchers[index]
    as IEventDispatcher).addEventListener(StyleEvent.ERROR, styleSheetFileFailed);}
    In the complete event I try to trace that the particular file has been loaded to see whether it has been loaded... But i don''t see it there...

  • [Unload SWF] appears in console and hangs app

    Occasionally, "[Unload SWF] path:main-debug.swf" appears and
    kills any HTTPService calls that are made.
    The app behaves as such:
    1. About 4 HTTPService calls are made at once, using
    different HTTPService instances.
    2. Occasionally, in the debug console a "[Unload SWF]..."
    appears, showing the path to my app. Sometimes it appears once for
    every webservice call that I make.
    3. Each webservice that gets the "[Unload SWF]" will never
    return and hangs forever.
    Sometimes, I'll also see a "[SWF] path:main-debug.swf"
    message in the console, at which point the webservices will hang
    again. If I click "Cancel" in my app, then try it again, they will
    sometimes magically work (and I don't get those [Unload SWF]
    messages).
    Any help would be greatly appreciated!
    -Michael Whitaker:confused;

    Unbelievable...
    I think I may have found the problem and solution:
    The way I was using the HTTPService component was through a
    seperate class which itself contained the httpservice that I was
    instantiating and calling on a per-need basis. The function I was
    using to call my web service needs accepted two function pointers
    (or Function types) which were called on a ResultEvent or a
    FaultEvent (from the HTTPService). I was using lamba functions
    (inline functions) in the method call. That is what seemed to be
    the problem. As soon as I moved the lamba functions outside ,into
    real functions, and just passed their reference through my method,
    everything worked.
    I've noticed several problems with lamba functions, all of
    which are very unfortunate (because I would use them more, but they
    are so buggy):
    1. A lamba function sometimes has some weird scope. At times
    calling "this.something" fails from within the lamba function as
    'this' is null. Ex:
    class Bob
    public Bob()
    this.addEventListener(Event.ENTER_FRAME,
    function(e:Event):void { trace("this: " + this.toString()); },
    false, 0, true);
    (Note: this is 1% psudo code (uncompiled).) "this" will
    sometimes be null (depending on where the lamba is used).
    2. If, using the above code, you were to instantiate several
    Bobs at a time, and add them to the displaylist, sometimes only ONE
    of the instances will actually call their lamba function on
    enterframe; the others won't. I'm not sure why this happens, but I
    think multiple instances of the same class using a lamba function
    tends to conflict in memory or something. (or in the special
    lamba-scope).
    3. At times, as per my problem in this thread, a lamba
    function won't even be called. I've solved this by pulling out the
    lamba functions and placing them in real functions, then just
    passing the pointer across.
    I guess the debugger sending [Unload SWF] and [SWF] messages
    were just a coincidence (unless they somehow affect lamba
    functions). I'm going to continue testing this to verify that the
    problem has gone away. If it hasn't, I'll probably start a new
    thread.
    Thanks for your help mike_morearty!

  • [SWF] and [Unload SWF] in Debug mode

    I am debugging my application and I am noticing some strange output in my console window.
    I will get the same line duplicated, it looks like this:
    [SWF] C:\Users\Me\Desktop\Development\flash\bin-debug\main.swf
    [SWF] C:\Users\Me\Desktop\Development\flash\bin-debug\main.swf
    [SWF] C:\Users\Me\Desktop\Development\flash\bin-debug\main.swf
    Then at a later state in the application I see this:
    [Unload SWF] C:\Users\ Me\Desktop\Development\flash\bin-debug\main.swf
    [Unload SWF] C:\Users\ Me\Desktop\Development\flash\bin-debug\main.swf
    [Unload SWF] C:\Users\ Me\Desktop\Development\flash\bin-debug\main.swf
    Can someone exaplain to me what this means, and why I see duplicates of the exact same lines?

    I would like to add a question to this topic, but instead of describing it, I would like to refer to this forum, where it was described very good: http://www.gotoandlearnforum.com/viewtopic.php?f=33&t=28730
    In short:
    When the loader object is only referenced by a local variable within a method and there's no other reference to the loader, other than the EventListener, the loaded SWF file is being sporadically unloaded (by the GC perhaps) before I am able to access the loader.content! That's kind of a bug, I guess and not acceptable!
    So any help would be much appreciated!
    Regards,
    Matthias

  • AIR Debugger crashing in Flash Builder [Unload SWF]?

    I'm using the latest 4.5 Flash Builder and have been working on an Android app for the Motorola Xoom.  It works great and the development environment is borderline flawless.  I have noticed one thing that keeps happening.  When running my app on the laptop OR the Xoom directly from FB it works great.  When I debug the app on my laptop it also works great, but sometimes when I try and debug on the device itself I get about 5 seconds of runtime and then the app mysteriously crashes on the device (goes to home screen) and the last thing shown in the console is [Unload SWF].
    Any ideas?  I have no doubt it is something I am doing but have been unable to find any solutions.
    Thank you!

    I have this problem but I have found the reason.
    I'm using external graphics from a .swc file. This problem appear when I'm loading an instance of a Movieclip that have inside another movieclip with property "visible" set to false. I have set it to true again on Flash, export again .swc, and set visible to false by code, while I have just created de object on run-time before add it to scene.

  • Need to load and unload swf from single htm file

    I need to load or unload swf file or we can say that i need load 3 project one by one in current window

    mit,
    So are you saying you need to have one swf file call a second file to play, then call a third to play...
    Which Captivate version are you using?
    Are the swf files all captivate published swf's?
    Do you have access to Flash Professional and if so what version?
    how are you running your file, is it scorm packaged or just html based?
    I may be able to help with your issue, but need these details.

  • Unloading swf but the swf sound still play

    after unloading swf
    the sound of swf still play ??
    how i can stop the swf completely?

    if u mean using
    SoundMixer.stopAll();
    before the loading swf code
    i try that
    and still playing
    thats the code of scene 1
    stop();
    import flash.events.Event;
              SoundMixer.stopAll();
    var scene1s:Loader = new Loader ();
    scene1s.load(new URLRequest("scene1.swf"));
    addChild(scene1s);
    addChild(entery_bt);
    entery_bt.addEventListener(MouseEvent.CLICK, ToMainEntery);
    function ToMainEntery(event:MouseEvent):void
              scene1s.unloadAndStop();
              MovieClip(this.root).gotoAndPlay(1, "Scene 2");
    so he goes to scene 2 with the sound still playing ?

  • How to unload swf from anather swf

    I am calling 3 different swf in to test.swf.
    now i want to unload only 1 swf from test.swf
    can any 1 tell me how it is possible i am trying
    with removeMoviClip() and unloadMovie()
    but its of no use.
    regards
    Justbipin

    Maybe that's not really what you're doing?
    I would guess you rather have
    loadMovieNum("myFiLe.swf",99);
    This would be unloaded with
    unloadMovieNum(99);
    Good luck
    Wolf
    PS Or do you have a container movieClip called "99" to fool
    us all? :-)
    PPS watch your capitalization. If you call a file "myFiLe"
    (and mis-spell it somewhere) it might work on Windows, but not on
    Unix-derivatives. A potential source of "Why did it work when I
    tested it but not when I uploaded it?"

  • How to unload swf

    I am calling 3 different swf in to test.swf.
    now i want to unload only 1 swf from test.swf
    can any 1 tell me how it is possible i am trying
    with removeMoviClip() and unloadMovie()
    but its of no use.
    regards
    Justbipin

    justbipin wrote:
    > no , i am directly call them into my swf as follows,
    > loadMovie("myMovie.swf",99);
    >
    > not on specific level or any where.
    > simplly call that movie in swf.
    this action is wrong to start with.
    loadMovie refers to movie loaded in movie clip holder.
    Now, your action uses 99 as expression which in fact should
    be (in quotes) holder instance name.
    loadMovie("file.swf", "holder");
    To load movie in level you will need loadMovieNum action
    loadMovieNum("file.swf", 99);
    where 99 is the level number.
    You need to define level or holder clip otherwise you have no
    way to refer to that loaded clip.
    Regards
    Urami
    Happy New Year guys - all the best there is in the 2006 :)
    <urami>
    http://www.Flashfugitive.com
    </urami>
    <web junk free>
    http://www.firefox.com
    </web junk free>

  • Unloading SWF movie

    Hi,
    I've been working on a CD-Rom presentation with Flash and so
    far I was mostly using AS1 and AS2 to built it. I started to learn
    some AS3 for a part of the presentation but now I'm running into
    issue, here's the main one:
    I'm loading different SWF movie one on top of the other, and
    unloading them as needed, now this is very easy with AS1 (loadmovie
    and unloadmovie function are simple to use), but when I'm loading
    my file built with AS3 I can't figure out how to unload it. The AS3
    movie is loaded on the Level 5, I just want to make sure that when
    I'm unloading the file it's not unloading everything else.
    Can anyone help me.
    Yann Poirier

    Disregard, I found my answer

  • Button to navigate and unload swf

    I have the following code to load an external swf by clicking a button. It works fine.
    btn_01_01.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);
    function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
    var url:String = event.currentTarget.name+".swf";
    fl_Loader.load(new URLRequest("loads/TEST_VID_AS3.swf"));
    I also have a button that takes me to another place on the timeline.
    this.btn_back_main.addEventListener(MouseEvent.CLICK,fback_main);
    function fback_main(evt:MouseEvent)
    MovieClip(this.root).gotoAndPlay("main");
    But the loaded swf is still visible.
    I would like that button to also unload the loaded swf.
    Can anyone tell me if it's possible and suggest code?
    Thank you in advance.

    this should do it (assuming the btn to remove it is called "btn_remover"):
    var ld:Loader = new Loader();
    btn_01_02.addEventListener(MouseEvent.CLICK, v);
    function v(e:MouseEvent):void {
         ld.load(new URLRequest("loads/TEST_VID_AS3.swf"))
         addChild(ld)
    btn_remover.addEventListener(MouseEvent.CLICK, removeSwf);
    function removeSwf(e:MouseEvent):void {
         ld.unloadAndStop();
    firstly, i moved the Loader definition outside of the function (otherwise it gets removed at the end of the function and cant be accessed later)
    then i added event listener to remove button to call removeSwf function - which calls unloadAndStop() on the loader object
    fyi, i suggest you use more descriptive names for your buttons and functions otherwise you'll find it harder to work out whats going on if you come back to it after a break.

Maybe you are looking for

  • Iphone not recognizing SIM card

    Since I bought my Iphone about 5 months ago, a few times it would say that there is no SIM card inserted, when in fact there had been one. I would remove and reinsert the card or do a hard shut down and restart and the problem would go away. Yesterda

  • Video will not play in IE but works in other browsers

    I have a flv video on a page which was placed there using Dreamweaver CS4.  It plays in all other browsers I test it in except IE7. (Firefox, Chrome, Safari) Others verify it dooesn't play in IE7 also.  Doesn't even play when I test in 'preview in br

  • ICloud payment plan

    I used to make one time payment for my iCloud storage plan, but I see now I have been charged on a monthly basis! Is there a way where i can switch back to one time payment? Thank you!

  • AUTHORITY (urgent)

    Hi I have a requirement, i have approx 50-60 Z report in my system.and i want to restrict my enduser to see or access the data of other palnt(our manufacturing unit). suppose i have user's A B and C .User A is allowed to view data of plant1 and user

  • 10.5.3 Update won't update

    For some reason, the new 10.5.3 update won't install for me. I go to Software Update, and it shows me three updates available at the moment (Quicktime, Mac OS X Update, and Airport Utility). I click the install button and type my password to restart,