Unload the SWF using SWFLoader

Hello

I have a main app where I use a SWFLoader for loading a second application.

In the second application, I want to put a (Close) button and when I click it I want to download this application.

Is it possible to do this?

I know that I can unload a swf file using the SWFLoader unloadAndStop method, but how do I access it the loaded application?

I think a different approach would be adding eventlisteners to the loaded swf but I do not know how.

Can someone help me?

Thanks in advance,

Alberto

Hello

@Alberto

I think a different approach would be adding eventlisteners to swf loaded but I don't know how to do this.

I think you can use the event type to custom or built-in to send information to the hosting applications and SWFLoader * has * integrated dedicated routine to the context loaded unloading - which includes the removal of event listeners added to swf-types on content charge (Yes, there is a way in the kit Flex SDK to access applications above, but most often that is not advisable to access the methods and properties of the parent that it binds tightly) content together).

For your initial claim could start listening to the custom events when the load completes and removes loading app like this:

http://ns.Adobe.com/MXML/2009.

xmlns:s = "library://ns.adobe.com/flex/spark".

xmlns:MX = "library://ns.adobe.com/flex/mx" >

protected function chidLoadedHandler(event:Event):void

{

swfLoader.content.addEventListener (Event.CLOSE, unloadChildHandler);

};

protected function unloadChildHandler(event:Event):void

{

swfLoader.content.removeEventListener (Event.CLOSE, unloadChildHandler);

swfLoader.unloadAndStop (true);

}

]]>

<>

Width = "100%" height = "100%".

source = "ChildApplication.swf"

Complete = "chidLoadedHandler (Event)" "

ID = "swfLoader" / >

While the demand of your children simply:

http://ns.Adobe.com/MXML/2009.

xmlns:s = "library://ns.adobe.com/flex/spark".

xmlns:MX = "library://ns.adobe.com/flex/mx" >

protected function unloadMeHandler(event:MouseEvent):void

{

We will ship event 'CLOSE' - this could be the type of custom event

but I think it's just enoguht heres

var closeEvent:Event = new Event (Event.CLOSE);

root's highest - if it's 'content' more high display object so

this.root.dispatchEvent (closeEvent);

}

]]>

Don't know if it's more evidence of ball or recommended solution but could be the starting point,

Kind regards

Peter

Tags: Flex

Similar Questions

  • [Help] Button that closes or unloads the SWF itself and charge another.

    Hello! Could someone help me please?

    Maybe my question seems little obvious to you, I ask patience ^ ^

    I'll summarize as briefly as possible .. Imagine a presentation, interactive animation and full, with many ways or different possibilities...

    The method I use is to divide it into many different rulers, otherwise it would be ridiculously heavy...

    But that's the problem: when I want to load another SWF, he eventually overwrite the original and will become more slow and overloaded, because it consumes too much memory and frame rate decreases each new SWF loading...

    I wonder if there is a way to unload the SWF itself by button and move on to the next...

    Open
    LER foneticamente

    If you have a single swf file main who must simply acts as a container that loads of the FSV of presentation, you can use the Loader class to load the presentation files, and it includes methods to unload the files loaded as well.  Find the class Loader in the help documentation if you need more information.

  • Unload the SWF file

    Hello

    I am developing a portal application.  I load all the swf files in a configuration of trusted sandbox.

    When I unload the swf file as follows (note automatically load the value true):

    swfLoader.source = null;

    swfLoader.validateNow ();

    But when I run the Profiler on that I noticed that the application loaded the swf file is never garbage collected (i.e. There is an instance for each time I load the swf file).

    When I look at what has references to the application, I get the following:

    profiler.jpg

    Is there a standard method to remove the reference to the application so that it is unloaded.  Currently, my request is vanilla and there is nothing in the mxml.

    I doubt that the SystemManager is the issue.  I would look at the amount and names

    each class in the snapshots to see what the difference is.  I think so

    someone wrote recently having to unplug the RO in order to allow

    unloading.

  • Unload the SWF

    I have an app that loads a SWF using the SWFLoader.  I can't seem to get discharged.

    1 State1 - user clicks on a text with a click handler, and thinks State2

    2 State2 is a component called 'main' demand, which includes a

    SWFLoader... source = "example.swf" id = "swfLoader_ID"...

    3. State the main applicatino 2 has a 'skip' button which must discharge the example.swf.  I use

    swfLoader_ID.unloadAndStop ();

    which works very well in other situations, but not in this one.  Any help is apprecitaed.

    Thank you.

    I don't know if this could be useful for you, but here goes: once I had to load a SWF (video) file and use the class Loader.  I had a reference to this class loader and I called the unload method, however, the video was still playing but it has disappeared from the scene, what I had to do was "withdraw" all references to the magazine, for example, making this variable overall (of type charger) in a simple local variable in a method, in this way, as long as the SWF file was no references I could solve the problem.

    Hope that helps. Think of this part... removal of references...

    Kind regards

    Dev

    http://Csapp.zzl.org

  • Load and unload the swf file

    I am currently using AS2.

    I create a button instance named 'myBtn' and I want it to load the external swf "test2.swf" call all to unload the current swf file named "test1.swf" when you press on / release.

    that fact is I put the following code under mybtn:

    We (Press)

    {

    unloadMovie ("test1.swf");

    loadMovie ("test2.swf", 1);

    }

    the result was that the "test2.swf" was loaded successfully, but the "test1.swf" fail to unload.

    Any help is welcome

    AS2... Scope is your problem. When you are inside the function for delivery you tell the button you used to unload test1.swf of inside of this button (which it is not located in).

    You are probably using the root timeline, so I'll take a bet that it works:

    (press)

    {

    _root.loadMovie ("test2.swf");

    }

    If you want to follow the progress of loading between them, it is a bit more complex.

  • How to load external swf file and unload the swf file parent?

    I have a question. Let's say I have file1.swf, file2.swf and file3.swf, how can I link this 3 files together.

    Let's assume that file1.swf is the main content file, but as I load file2.swf, I want the file1.swf get replaced by file2.swf. How could unload file1.swf at that time, so that my file2.swf will become the main content file?

    and even once, when my current post file2.swf and I want it get replaced by file3.swf tinkle of a button. so that i can unload the file2.swf and let them file3.swf become the main content file...
    Anyone have ideas on this?
    Thank you..

    If you're publishing to fp 10 + use:

    var loader: Loader = new Loader();

    var urlR:URLRequest = new URLRequest();

    addChild (loader);

    Btn1.addEventListener (MouseEvent.Click, f);

    btn2.addEventListener (MouseEvent.Click, f);

    function f(e:Event):void {}

    {if (Loader.Content)}

    loader.unloadAndStop ();

    }

    {if(e.currentTarget==btn1)}

    urlR.url = "file2.swf";

    } else {}

    urlR.url = "file3.swf";

    }

    Loader.Load (urlR);

    }

    p.s. Please check the useful/correct, if there is.

  • Embedded the swf using the external video (FLVPlayback) error #2035 / #2044

    I struggled with this a lot recently, and I don't even know if it's at all possible.

    I am currently working on a project where I am incorporating a .swf inside another .swf.

    The built-in .swf file however also uses the external videos FLVPlayback to load component, this is where the problem starts.

    When you publish the .fla project I get the 2035 # IOErrorEvent when tracing the problem I get the #2044, it is to be expected however.

    The embedded swf is always looking for external videos, but since the new ROOT is the swf file, in which it is integrated, it will not find these videos.

    I need to know if there is a way I can specify or link these external videos required by the embedded swf file FLVPlayback component.

    I really can't be bothered again all the video content and their incorporation in the timeline.

    Thank you.

    The code inside the SWF will trigger these errors will occur if you don't have the source for sovereign wealth funds to stop it.

    If you do then you can just access SWF files loaded the mother/stub swf you have and check anything with a name or instance on the display list with the code, as all of the FLVPlayback components. You can then tell them the correct path.

    Otherwise, it would take something like a rewrite mod apache to redirect paths incorrect film to the correct path.

  • How to view the swf using the full screen and redirecting to a url

    Hello

    I have 2 questions:

    Question 1 – I have a flash swf file and I want to display in the browser in full mode, which means it has to adapt the browser, I tried to add

    fscommand("fullscreen", "true");

    in the first image of a lyaer, but it does not work.

    Question 2 - How to redirect to another page at the end of the video swf, I tried to add:

    stop(); 

    navigateToURL( new URLRequest("*www.microsoft.com*"), "_self");

    in the last image but it does not work.

    Thank you very much for your assistance!

    Terry

    use:

    for an application without air, this should be in response to an intervention of the user (such as a mouse click).

    stage.displayState = "fullScreen";

    navigateToURL (new URLRequest ("http://www.adobe.com"), '_self');

  • Link to the page at the end of the SWF using navigatetoURL? IMPOSSIBLE?

    Hi all

    I'm at the end of my absolute roll. I'm an advanced user, Photoshop and After Effects, with a little knowledge by using HTML and CSS. Today is my first day of Flash.

    You would think that it would be simple to redirect to a different page in a certain range. I've been sitting here for 5 hours searching forums and tutorials and still are slow to arrive at the answer.

    Here's what I have:

    I clicked on the last keyframe and in the Panel shares entered:

    flash.net.navigateToURL (URLRequest ("http://www.mywebsite.com/index.html", "_self"));

    I tried many (many) other iterations. Please, I beg you, tell me how it can be done using the step by step instructions. The most important I need a complete example of actual to use code.

    Why is it if very very difficult to do? I like how the scripts work in After Effects. I like other Adobe software. Why Flash is so bulky?

    I use CS4 and I will be eternally grateful for any help.

    It's a programming language. and like all the others that it takes time to acquire a comfort level... in that you need the framework is...

    navigateToURL (new URLRequest ("http://www.mywebsite.com/index.html"), "_self");

  • unload the SWFs

    Hi all


    I tried to solve this problem for two days, and nothing helped...

    I have a menu, which works with an xml file.
    the XML contains the specific code that fires the .as file:

    HTML code:
    <buttons>
         <button name="HOME" linkType="custom" link="home.swf" />
         <button name="ABOUT" linkType=" _custom" link="about.swf" />
         <button name="BLOG" linkType=" _self" link="contact.html" />
        <button name="CONTACT" linkType=" _self" link="contact.html" />
     
    </buttons>
    now, the .as file, I load the movies:

    var request: URLRequest = new URLRequest (link);
    var loader: Loader = new Loader()
    Loader.Load (request)
    var swfContainer:MovieClip = new MovieClip;
    this.addChild (swfContainer)
    swfContainer.addChild (loader);

    When I press the button home, for example, the House takes over...
    then I press the button, and it loads as well, but the House continues to play on the back...
    How can I make content for the House to disappear when you click another button?

    because the code works for all buttons, there must be something generic... It works for the anybutton event that is clicked...

    any suggestions?

    Quite happy.

    the error 1180 is the result to your document class extend the sprite class.  have it extend the movieclip class and you can attach code to frames.

  • How can I unload external SWF?

    I use the following code to load an external SWF file. I want to unload the SWF (Clock.swf) after 10 seconds (automatically). How can I? I use greensock class.

    import com.greensock;

    com.greensock.easing import. *;

    com.greensock.plugins import. *;

    import com.greensock.events.LoaderEvent;

    var mySwf1:SWFLoader = new SWFLoader ("Objects/Clock.swf", {height: 200, width: 200, onComplete:completeHandler1, container: ClockContainer});

    mySwf1.load ();

    function completeHandler1(event:LoaderEvent):void {}

    TweenLite.to (event.target.content, 0, {alpha: 0});

    TweenMax.fromTo (event.target.content, 3, {x: 0, y: 0, width: 200, height: 200, alpha:. 1}, {x: 0, y: 0, width: 200, height: 200, alpha: 1, delay: 5.});

    }

    Download:

    mySwf1.dispose (true);

    Unload after 10 seconds:

    setTimeout (function () {mySwf1.dispose (true)}; 10000);

  • Cannot unload external .swf and return to section 1

    I tried several suggestions on this forum to solve my problem, but it is clear to me miss me something, because I'm a Flash of NOVICE developer. I have everything works in my Flash file, EXCEPT that I want to use this code to play a .swf file. When the SWF is done playing OR that the user clicks on the "back to the main Menu button", they return to frame 1.

    Stop();

    Log_In.addEventListener (MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_7);

    var fl_Loader_7:Loader;

    var fl_ToLoad_7:Boolean = true;

    function fl_ClickToLoadUnloadSWF_7(event:MouseEvent):void

    {

    If (fl_ToLoad_7)

    {

    fl_Loader_7 = new Loader();

    fl_Loader_7.load (new URLRequest ("NAV01BBEC293.swf"));

    addChild (fl_Loader_7);

    fl_Loader_7 .x = 19;

    fl_Loader_7 there = 67;

    }

    on the other

    {

    fl_Loader_7.Unload ();

    removeChild (fl_Loader_7);

    fl_Loader_7 = null;

    }

    Toggle if you want to load or unload the SWF file

    fl_ToLoad_7 =! fl_ToLoad_7;

    }

    Main_btn.addEventListener (MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_9);

    function fl_ClickToGoToAndPlayFromFrame_9(event:MouseEvent):void

    {

    gotoAndPlay (1);

    }

    Games of .swf files and when I click "Back to main Menu" button, that some items display of frame 1. The .swf file is always loaded to hide items that need to display the frame 1. I've attached a screenshot of what happens when I click on the button "back to the main Menu.After_click_Main_Menu button.png

    Here is a screen should look like shot of what framework 1.

    Frame_1.png

    I'm on a very tight schedule, any help would be most appreciated!

    Looks like I got the order backwards (or Adobe did when they christened)...

    try... fl_Loader_14.unloadAndStop ();

  • need help to unload a .swf

    I am using flash CS5, AS3

    I'm a huge module having a 'nodal point' (table of contents) which contains all the links to the other slides that are individual .swf files.

    The question is, from the Center, I click on the link to open a swf file and it starts to play.  If the button that returns you to the hub are pushed before the entire .swf plays through, symbols and interpolations of the swf that has been simply discharged, always appear on top of the hub and continue playing.  someone knows how can I fix?

    Code to frame 1 of all sovereign wealth funds:

    This.btn_hub.addEventListener (MouseEvent.CLICK, SWFhub);

    var fl_Loader:Loader;

    This variable keeps track of if you want to load or unload the SWF file

    var fl_ToLoad:Boolean = true;

    function SWFhub(event:MouseEvent):void

    fl_Loader.Unload ();

    removeChild (fl_Loader);

    fl_Loader = null;

    fl_Loader = new Loader();

    fl_Loader.load (new URLRequest ("Slide HUB.swf"));

    addChild (fl_Loader);

    }

    SoundMixer.stopAll ();

    any help would be appreciated!

    -= Sondax =-

    someone who will probably need to download and to repair your file for you.

  • How to unload external SWF?

    I was finally able to work on a way to fix and preload external SWF files - now I'm looking to understand how to unload the SWF external on a mouse event so that a new SWF file can be played.
    I googled this to death all day and have resulted in nothing of what seems to work for me.
    Below is are code so far... does anyone know what I need to add?
    Help, please...

    I have it working! YAY!
    I learned a lot from Andrei1 - fantastic help... unfortunately I still couldn't the code work...
    I bought 'Visual Quickstart Guide ActionScript 3.0' and tried some of their code mixed with some of my own (with help from the knowledge I gained from Andrei1 - THANKS again legend)...
    In any case, the resulting code is as below - which you charge my external SWF files and then discharge them with a click of mouse - FANTASTIC! Hope this helps others out there with the same problem.

  • Unload and stop the swf from scene

    Hello

    I am a newbie in Flash and Actionscript. I need to give links to about 20 files swf via the menu.swf buttons. I am able to give links. But when I come back by clicking the HOME button held in the newly loaded swf audio files are always played in the background.

    Yes, there are audio files playing in the back for each slide in the new FSV. Then click the link even menu.swf again once the files are played with the old incomplete file. It's really intense.

    I need to unload the scene completely when I return to menu.swf by clicking the HOME button on one of the 20 categories.

    I used unloadAndStop but it does not. I hope I'm mistakes of committing to a place but could not provide.

    Need help!

    FOR THE HOME BUTTON:


    var _content:Loader = new Loader();

    function loadContent(content:String):void {}

    If (_content! = null) {}

    _content.unloadAndStop (true);

    removeChild (_content);

    _content = null;

    }

    var loader: Loader = new Loader();

    Loader.Load (new URLRequest (content)); -> > > > I don't really know what to put in this :-(

    _content = addChild (loader) like charger;

    }

    Home_Button.addEventListener (MouseEvent.CLICK, home);

    function home(event:MouseEvent) {}

    _content.unloadAndStop (true);

    var homeSWF:URLRequest = new URLRequest ("demo.swf");

    _content. Load (homeSWF);

    addChild (_content);

    }

    MENU.swf BUTTON

    var loader: Loader = new Loader();

    Category1_Button.addEventListener (MouseEvent.CLICK, category 1);

    function category1(event:MouseEvent):void {}

    var Category1SWF:URLRequest = new URLRequest("Category1.swf");

    Loader.Load (Category1SWF);

    addChild (loader);

    }

    I think that there is a question of terminology.

    your main swf is the SWF that is embedded in your html page.  It is the first swf to display, and it can not be unloaded using actionscript.

    It must contain the loader, the only case of Loader, you need.

    This main swf may or may not be main.swf.

    in your main swf file, you must use:

    /////////////////////////////////

    var loader: Loader = new Loader();

    addChild (loader);

    function loadF(fileS:String):void {}

    {if (Loader.Content)}

    loader.unloadAndStop ();

    }

    Loader.Load (new URLRequest (fileS));

    addChild (loader);

    }

    function unloadF (): void {}

    {if (Loader.Content)}

    loader.unloadAndStop ();

    }

    }

    /////////////////////////////////////////

    do not change anything between the lines.

    ----------------------------------------------------

    your main SWF, if you want to load "catgoryxyz.swf", use:

    loadF ("categoryxyz.swf");  This argument in this line, you can and will change

    you main swf, if you want to unload all that is been loaded (and seem to go back to your file main swf), use:

    unloadF();

    ---------------------------------------------------

    Since the script a swf loaded (as categoryxyz.swf) principal, if you want to load "categoryabc.swf", use:

    MovieClip (this.parent.parent) .loadF ("categoryabc.swf");  the argument in this line, you can and will change

    If you want a swf to unload himself (and seem to go back to your main swf file), use:

    MovieClip (this.parent.parent) .unloadF ();

    -----------------------------------------------------------------

Maybe you are looking for