How to unload the external .swf file when move on to other section?

Hi,
The following code provided by Mr. kglad works great in loading an external .swf file onto stage. Now, when I click on Contact (Button), the external .swf file to be removed completely. How to code on contact (Button) to work it out.
Gallery.addEventListener(MouseEvent.CLICK, GalleryClick);
function GalleryClick(e:Event):void{
if(currentClip != Gallery_mc){
currentClip.visible = false;
Gallery_mc.visible =true;
currentClip =Gallery_mc;}
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ClipLoaded);
loader.load(new URLRequest("Gallery.swf"));
function ClipLoaded(e:Event):void{
Gallery_mc.addChild(loader);
loader.x=0;
loader.y=120;
loader.width=1000;
loader.height=700
I tried the following code for Contact_btn to unload the Gallery.swf file which throws an error: 1120: Access of undefined property loader.
Contact.addEventListener(MouseEvent.CLICK, ContactClick);
function ContactClick(e:Event):void{
if(currentClip != Cotnact_mc){
currentClip.visible = false;
Cotnact_mc.visible =true;
currentClip = Cotnact_mc;
Gallery_mc.removeChild(loader);}}

like so:
Gallery.addEventListener(MouseEvent.CLICK, GalleryClick);
function GalleryClick(e:Event):void{
if(currentClip != Gallery_mc){
currentClip.visible = false;
Gallery_mc.visible =true;
currentClip =Gallery_mc;}
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ClipLoaded);
loader.load(new URLRequest("Gallery.swf"));
function ClipLoaded(e:Event):void{
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, ClipLoaded);
Gallery_mc.addChild(loader);
loader.x=0;
loader.y=120;
loader.width=1000;
loader.height=700
I tried the following code for Contact_btn to unload the Gallery.swf file which throws an error: 1120: Access of undefined property loader.
Contact.addEventListener(MouseEvent.CLICK, ContactClick);
function ContactClick(e:Event):void{
if(currentClip != Cotnact_mc){
currentClip.visible = false;
Cotnact_mc.visible =true;
currentClip = Cotnact_mc;
if(loader){
if(loader.stage){
gallery_mc.removeChild(loader);
loader.unloadAndStop();  // for fp 10+
loader=null;  // if loader no longer needed

Similar Messages

  • Load and unload the external swf file using AS3(for window, IOS and android)

    For the external swf file loading, I use this code
    load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene02.swf"), _lc);
    its working great but I don’t know how to unload the loaded swf files (looking: unload one by one and unload all)
    in AS2 we have
    on (release) {
              loadMovieNum("scene2.swf", 1);
              unloadMovieNum(2);
              unloadMovieNum(3);
    but i need in AS3

    Now I use this code and this time I got these compiler errors
    package {
                    import flash.display.SimpleButton;
                    import flash.display.MovieClip;
                    import flash.events.MouseEvent;
                    //import flash.display.URLRequest;
                    //import flash.display.Loader;
                    import flash.events.Event;
                    import flash.system.ApplicationDomain;
                    import flash.net.URLRequest;
                    import flash.system.LoaderContext;            
                                    public class load1 extends SimpleButton {
                                                    var loadit:Loader;              
                                                    public function load1() {
                                                                    this.addEventListener(MouseEvent.MOUSE_DOWN, loadfile);
                                                    private function loadfile(event:MouseEvent):void {
                                                                    trace("you clicked me");
                                                                    loadit = new Loader();
                                                                    this.parent.addChild(loadit);
                                                                    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                                                                    loadit.load(new URLRequest("s01.swf"), _lc);
                                                    private function unloadfile(event:MouseEvent):void {
                                                                    loadit.unloadAndStop();

  • With seamlesstabbing unchecked, how to leave the capitvate swf file?

    Hi,
    I have a captivate project which is in a popup window and with a link after the captivate swf file.
    I have the seamlesstabbing unchecked so user may tab through and focus in the swf.
    And I want at the last slide, user can leave the captivate swf, and advance tab to the link.
    I have tried Exit but this will close the popup window. I also tried javascrip... captivate.blur() which not worked too.
    Does anyone know how?
    Thanks,
    Misachang

    Hi,
    I have a captivate project which is in a popup window and with a link after the captivate swf file.
    I have the seamlesstabbing unchecked so user may tab through and focus in the swf.
    And I want at the last slide, user can leave the captivate swf, and advance tab to the link.
    I have tried Exit but this will close the popup window. I also tried javascrip... captivate.blur() which not worked too.
    Does anyone know how?
    Thanks,
    Misachang

  • How to config the web.xml file, when I use Richfaces + RI 1.2?

    Hi there:
    I want to use Richfaces + RI 1.2 to build a project. I don`t know how to config the web.xml file.
    By the way, my web server is Tomcat 6.0, my JDK's version is 6u6. I don`t want to use the facelets.
    thanks.
    lxm

    just add this before *</web-app>*
    <context-param>
           <param-name>org.richfaces.SKIN</param-name>
           <param-value>blueSky</param-value>
      </context-param>
      <filter>
           <display-name>RichFaces Filter</display-name>
           <filter-name>richfaces</filter-name>
           <filter-class>org.ajax4jsf.Filter</filter-class>
      </filter>
      <filter-mapping>
           <filter-name>richfaces</filter-name>
           <servlet-name>Faces Servlet</servlet-name>
           <dispatcher>REQUEST</dispatcher>
           <dispatcher>FORWARD</dispatcher>
           <dispatcher>INCLUDE</dispatcher>
      </filter-mapping>

  • How to deploy the web.xml file when trying to use the JSP SDK from SAP?

    I want to use the adduser.jsp which downloaded form SAP SDK samples to add user in BO, but I cannot run it sucessfully. I believe it's caused the web.xml file was not deployed appropriately.
    could you please teach how to deploy the web.xml file for the JSP samples ?
    Could you show me some sample of web.xml for the SDK jsp files? Thank you very much!

    Ensure that you have followed below directory structure while deploying your web application.
       web_application_name
          WEB-INF
             lib
             classes
    web.xml must be placed in WEB-INF. Ensure that you have included all the jar files and other necessary files in your application.
    For more information refer to the below link:
    http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/devsuite.htm
    Regards,
    Anuj

  • How can I call in swf file to movie clip?

    Hi all ...
    This is my first post for advise, although fairly conversant
    with flash and as2.
    I am developing a new full screen background style website
    and have menu buttons contained within a movie clip (nav_c1) ...
    this re-aligns to the top centre of a page when user scales the
    browser window.
    I then have the content area (centre_content) movie clip ...
    this realigns to the centre of the page when a user scales the
    browser window.
    I have scripted the menu buttons to goto a labelled frame in
    the main timeline but I need, when at the labelled frame, to be
    able to call/load in an external swf file to play 'inside' the
    centre_content movie clip?
    for example:
    If I click my news button the flash file moves to the frame
    label news on the main timeline. This then shows a duplicate of the
    moive clip 'centre_content' which is called 'centre_news'. I need
    to be able to call/load an external news.swf, containing all the
    animated news info, to sit and play 'within' the movie clip
    'centre_news' ... so that it is effectively contained 'within' the
    movie clip file but loaded in place from an external swf file.
    Can anyone help please?
    I can post a rough working example online if need be.
    Many thanks
    A puzzled Adrian
    ps: I don't think I am needing to load the swf to a level 1
    area as I have tried this and instead of the swf file being loaded
    and contained within my movie clip file/area it instead seems to
    sit fixed on the main timeline (ie: not contained within the movie
    clip area).

    Thanks Sketchsta for you code. This looks like we're on the
    right lines as I see what the code is trying to do.
    Unfortunately though I can't seem to get this to work?
    I created a new file to get rid of other scripting that was
    going on and have placed a movie clip called centre_content onto
    the main timeline in frame 1 ... then I have applied your script to
    an actions frame above the movie clip also on frame 1. I change the
    path_to_file line with my swf name (callin.swf) which is a 1 frame
    flash file with some text on it ...
    ... but it doesn't bring in the callin.swf file ... it just
    shows the centre_content clip.
    Am i doing anything wrong?
    I also tried putting the script onto the first frame inside
    the centre_content movie clip but this doesn't appear to work
    either.
    Regarding the pre-loader ... can I simply build this into the
    swf file that is being called in to the movie clip?
    Thanks in advance for your support, it is much appreciated.
    Adrian

  • MORE - Why can't the exe of my project access the external swf files?

    Since this does not seem to have been answered the I'll raise it again!
    I have created 12 training modules and one menu module - see attached diagram.
    I need to deliver the training modules on cd/dvd to the students.
    I wish to create a player that the students can use that will open the menu and allow them to select the lesson they wish to view from that menu.
    I wish to have this happen in a stand alone player as we have experienced erratic playback issues when trying to use this same method via a web browser.
    I have created a single slide module executable that launches the menu, then from the menu each of the other modules are to open in the same window as the menu and be viewable by the student. Once the module has completed the student should be returned to the menu screen to pick the next learning module, again this all happens in one window.
    Currently this is not working. I have used Rollover slidelets as the buttons and the action available(Open another project) leads me to believe what I wish to do is easily possible from within Captivate.
    It's not working, I get no errors so I can "debug". The executable and all swfs are in the same directory and should open with no problems - but again they are not and without any error tracking I have no idea why.
    What I am trying to do is SIMPLE and should be - yet I have wasted more than 8 hours trying to make it happen.
    The above scenario has been possible in Director and Flash for more than 10 years. Being new to Captivate this seems completely possible from the options available.
    Captivate Aggregator is not a solution as it has too few customizable options for a fluid and non-confusing user experience.
    I tried to create a simple player in Flash, however then the TOC in each Captivate created .swf file cause problems when used.
    Anyone have any answers to this????

    Actually the option to open another project is precisely what you would use when linking EXE files in the manner I suggest.
    It has always worked for me but then again, I've not tested using Captivate 6 so I suppose it might have become broken.
    As for having dozens of files, there is actually a way to structure links so that you store certain content in folders that they would have to navigate to. I'm guessing here that you are thinking if all files are at the root level of the CD, it would be difficult to determine which is the "menu" file.
    There is also a way to use a freeware application that fools the computer into thinking files are being accessed from a web server. The application is called Server2Go and I've recommended it to others for deploying on CD. That way everything could be SWF based (smaller files).
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Remove / unload external swf file(s) from the main flash file and load a new swf file and garbage collection from memory.

    I can't seem to remove / unload the external swf files e.g when the carousel.swf (portfolio) is displayed and I press the about button the about content is overlapping the carousel (portfolio) . How can I remove / unload an external swf file from the main flash file and load a new swf file, while at the same time removing garbage collection from memory?
    This is the error message(s) I am receiving: "TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/removeChild()
    at index_fla::MainTimeline/Down3()"
    import nl.demonsters.debugger.MonsterDebugger;
    var d:MonsterDebugger=new MonsterDebugger(this);
    stage.scaleMode=StageScaleMode.NO_SCALE;
    stage.align=StageAlign.TOP_LEFT;
    stage.addEventListener(Event.RESIZE, resizeHandler);
    // loader is the loader for portfolio page swf
    var loader:Loader;
    var loader2:Loader;
    var loader3:Loader;
    var loader1:Loader;
    //  resize content
    function resizeHandler(event:Event):void {
        // resizes portfolio page to center
    loader.x = (stage.stageWidth - loader.width) * .5;
    loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    /*loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;*/
    addEventListener(Event.ENTER_FRAME, onEnterFrame,false, 0, true);
    function onEnterFrame(ev:Event):void {
    var requesterb:URLRequest=new URLRequest("carouselLoader.swf");
    loader = null;
    loader = new Loader();
    loader.name ="carousel1"
    //adds gallery.swf to stage at begining of movie
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requesterb);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    // stop gallery.swf from duplication over and over again on enter frame
    removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent):void {
    // re adds listener for contact.swf and about.swf
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
    var requester:URLRequest=new URLRequest("carouselLoader.swf");
        loader = null;
    loader = new Loader();
    loader.name ="carousel"
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    removeChild( getChildByName("about") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of gallery.swf
    MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    function Down1(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    var requester:URLRequest=new URLRequest("contactLoader.swf");
    loader2 = null;
    loader2 = new Loader();
    loader2.name ="contact"
    loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader2.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader2);
    loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    function Down3(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    var requester:URLRequest=new URLRequest("aboutLoader.swf");
    loader3 = null;
    loader3 = new Loader();
    loader3.name ="about"
    loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader3.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader3);
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    removeChild( getChildByName("carousel") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
    stop();

    Andrei1,
    Thank you for the helpful advice. I made the changes as you suggested but I am receiving a #1009 error message even though my site is working the way I wan it to work. I would still like to fix the errors so that my site runs and error free. This is the error I am receiving:
    "TypeError: Error #1009: Cannot access a property or method of a null object reference."
    I'm sure this is not the best method to unload loaders and I am guessing this is why I am receiving the following error message.
         loader.unload();
         loader2.unload();
         loader3.unload();
    I also tried creating a function to unload the loader but received the same error message and my portfolio swf was not showing at all.
         function killLoad():void{
         try { loader.close(); loader2.close; loader3.close;} catch (e:*) {}
         loader.unload(); loader2.unload(); loader3.unload();
    I have a question regarding suggestion you made to set Mouse Event to "null". What does this do setting the MouseEvent do exactly?  Also, since I've set the MouseEvent to null do I also have to set the loader to null? e.g.
    ---- Here is my updated code ----
    // variable for external loaders
    var loader:Loader;
    var loader1:Loader;
    var loader2:Loader;
    var loader3:Loader;
    // makes borders resize with browser size
    function resizeHandler(event:Event):void {
    // resizes portfolio page to center
         loader.x = (stage.stageWidth - loader.width) * .5;
         loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
    //adds gallery.swf to stage at begining of moviie
         Down();
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent = null):void {
    // re adds listener for contact.swf and about.swf
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
         var requester:URLRequest=new URLRequest("carouselLoader.swf");
         loader = new Loader();
         loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader.load(requester);
         } catch (error:SecurityError) {
         trace(error);
         this.addChild(loader);
         loader.x = (stage.stageWidth - 739) * .5;
         loader.y = (stage.stageHeight - 500) * .5;
    // sure this is not the best way to do this - but it is unload external swfs
         loader.unload();
         loader2.unload();
         loader3.unload();
    // remove eventlistner and prevents duplication of gallery.swf
         MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         function Down1(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         var requester:URLRequest=new URLRequest("contactLoader.swf");
         loader2 = null;
         loader2 = new Loader();
         loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);    
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader2.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader2);
         loader2.x = (stage.stageWidth - 658.65) * .5;
         loader2.y = (stage.stageHeight - 551.45) * .5;
    loader.unload();
    loader2.unload();
    loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         function Down3(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         var requester:URLRequest=new URLRequest("aboutLoader.swf");
         loader3 = null;
         loader3 = new Loader();
         loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader3.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader3);
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
         loader.unload();
         loader2.unload();
         loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
         stop();

  • How do I find the width of an external swf file that I am loading in

    I have loaded in an external swf file and it works fine.
    However, when I get the width dimensions of the movieclip that is housing the external swf file it gives me a '0' for the width.
    Thanks for your time.

    you must wait until loading is complete before trying to access the loaded objects width.  at that point you can determine the width,height of the onstage/backstage objects in frame 1 of the loaded swf.

  • What happens when the Main Flash is 25 fps and an external SWF file is 12 fps?

    Hello everyone,
    I have a Main Flash which is set to 25 fps. This Flash is
    used to load an external swf file which was created using 12 fps. I
    would like to know what really happens when the Main Flash loads
    the external swf file? Does the Main file forces the external file
    to be run on 25 fps or the swf file is run with its own 12 fps?
    Any ways, if someone can take the time and explain this, I
    would be greatful.
    Thank you very much and have a great day.
    Khoramdin

    the external swf plays at 25fps - all loaded movies will take
    on the frame rate of the parent movie.
    Chris Georgenes
    Adobe Community Expert
    mudbubble.com
    keyframer.com
    http://tinyurl.com/2urlka
    Khoramdin wrote:
    > Hello everyone,
    >
    > I have a Main Flash which is set to 25 fps. This Flash
    is used to load an
    > external swf file which was created using 12 fps. I
    would like to know what
    > really happens when the Main Flash loads the external
    swf file? Does the Main
    > file forces the external file to be run on 25 fps or the
    swf file is run with
    > its own 12 fps?
    >
    > Any ways, if someone can take the time and explain this,
    I would be greatful.
    >
    > Thank you very much and have a great day.
    >
    > Khoramdin
    >

  • FAQ: How do I load an external SWF file into a parent SWF file?

    A ton of Flash users visit Adobe’s we site every month wondering  about how to load an external SWF file from within another SWF.
    Adobe's own TechNote on the subject attempts to answer the basic question, along with some common follow-up questions, including:
    How do I load more than one SWF?
    How do I load a SWF into a specific location in the display list?
    How do I resize the loaded SWF?
    How do I set its X and Y location?
    Here are some additional resources that elaborate on loading content and on working with the display list:
    Sample files for the above TechNote. A set of 3 FLA and 3 corresponding SWF files, including a parent SWF and 2 SWFs that the parent loads.
    Help > AS3 Developer’s Guide > Loading an external SWF file
    Help > AS3 Developer’s Guide > Loading display content dynamically
    Loading multiple external SWFs within a main SWF – CreativeCow.net forums
    Video tutorial: ActionScript 101 – Episode 6: Adding named objects to the Stage. By Doug Winnie. An example of how to add the loaded external asset to the Stage and modify its location or other properties.
    Video tutorial: Preloading in ActionScript 3.0.  By Lee Brimelow. A slightly more complicated example, showing how to  make the parent SWF display information about the progress of loading  the external SWF.
    Tutorial: Loading and unloading SWFs - FlashAndMath.com
    This article provides several examples of how to communicate between a parent SWF file and the loaded SWF:
    SWF to SWF Communcation via ActionScript 3.0 (by kglad)

    quote:
    Originally posted by:
    NedWebs
    You now seem to want to get rid of the swf once it has loaded
    and played itself thru. To do that you would need to have something
    in the swf itself that triggers its removal in its last frame. The
    following might work...
    MovieClip(this.parent).removeChild(this);
    Unfortunately I couldn't get this to work. I placed it on the
    last frame of the SWF to be called - is that right?
    I am not sure I am doing it correctly...

  • Unloading an External SWF

    Hi,
    I'm building a site that has 7 sections. 1 section is a Photo Gallery for which I'm loading an external SWF file that is controlled by an XML file. Im doing this for allowing content editing any time.
    All of the other content on the site is one-time, no backend required.
    I've successfully loaded the external swf file into a loader in one of the frames. However, when I navigate away to the other 6 sections, I'm unable to unload the external SWF loader. How do I go about this?
    Here's my code that loads the external SWF in one frame:
    import flash.events.MouseEvent;
    //This creates a new instance of the loader object.
    var my_Loader:Loader = new Loader();
    //This creates a new instance of the URLRequest object that contains the
    //path to the external SWF.
    var my_url:URLRequest=new URLRequest("gallery.swf");
    //These listeners detect when the file has finished loading, and if the
    //correct file is loaded.
    my_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
    my_Loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
    //The load method then loads the SWF file into the loader object.
    my_Loader.load(my_url);
    //This will offset the load SWF file, so be appear at (20, 20) on the stage.
    my_Loader.x = 37.85;
    my_Loader.y = 74.90;
    //This function adds the external SWF to the stage.
    function finishLoading(loadEvent:Event) {
    addChild(loadEvent.currentTarget.content);
    //This function displays a message if the file is not found.
    function errorHandler(errorEvent:Event):void {
    trace("file missing");
    stop();
    Here's the code I'm using for the site navigation buttons. I tried adding my_Loader.unload(); for all of the button Event listener functions. Its still not working.
    import flash.events.MouseEvent;
    vinaybtn.addEventListener(MouseEvent.CLICK, vinay);
    function vinay(event:MouseEvent):void
        my_Loader.unload();
        gotoAndStop(2);
    priyabtn.addEventListener(MouseEvent.CLICK, priya);
    function priya(event:MouseEvent):void
        gotoAndStop(3);
    gallerybtn.addEventListener(MouseEvent.CLICK, gallery);
    function gallery(event:MouseEvent):void
        gotoAndStop(4);
    bestwishesbtn.addEventListener(MouseEvent.CLICK, bestwishes);
    function bestwishes(event:MouseEvent):void
        my_Loader.unload();
        gotoAndStop(5);
    invitationbtn.addEventListener(MouseEvent.CLICK, invitation);
    function invitation(event:MouseEvent):void
        gotoAndStop(6);
    rsvpbtn.addEventListener(MouseEvent.CLICK, rsvp);
    function rsvp(event:MouseEvent):void
        gotoAndStop(7);
    Any help would be much appreciated.
    Thanks,
    Sudarshan

    try:
    var mc:MovieClip;
    //This function adds the external SWF to the stage.
    function finishLoading(loadEvent:Event) {
    mc=loadEvent.currentTarget.content as MovieClip;
    addChild(mc);
    vinaybtn.addEventListener(MouseEvent.CLICK, vinay);
    function vinay(event:MouseEvent):void
        removeChild(mc)
        gotoAndStop(2);

  • How can I load an external SWF into a movie clip that's inside other movie clip?

    Hi.
    I creating my first flash (actionscript 3.0) website but I'm
    stuck with a visual effect I want to create.
    I have a window on my website called contentWindow. Every
    time you click a button this window is supposed to leave the stage,
    load the requested content and return to the stage.
    The sliding window is a movie clip with 83 frames, 21 to
    enter the stage, 21 to leave the stage again, 20 for nothing (its
    just to simulate the loading time) and 21 to return to the stage.
    Now my goal is, when the user clicks on a navigation button,
    the window exits the stage, loads an external SWF with the content,
    and then returns to the stage.
    I've the "window" movie clip with an instance name of
    "contentWindow". Inside there is another movie clip with an
    instance name of "contentLoader". The content that the user
    requested should appear inside the "contentLoader".
    Now, when the contentWindow leaves the stage, I get this
    error message:
    quote:
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at rwd_fla::MainTimeline/trigger()
    If I switch
    "contentWindow.contentLoader.addChild(navLoader);" for
    "contentWindow.addChild(navLoader);" it works fine, but the
    external SWF doesn't move with the window.
    How can I load an external SWF into a movie clip that's
    inside other movie clip?

    Hi,
    Recently, I have been putting together a flash presentation.
    And I am just wondering if the following might help you, in your
    communication with the said swf file:
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    onComplete);
    function onComplete(event:Event):void
    event.target.content.thinggy_mc.y -= 100;
    Not the best example, but this allows you to target a mc
    within an external swf file. I think if you look up this code, you
    will have an answer ;)
    Kind Regards,
    Boxing Boom

  • Loading external swf file in a new window

    Hi,
    I've got a few .swf files with video tutorials I've created using Captivate 4.
    I wanted to link them so I've created a main screen with menu with buttons in Flash.
    I've added AS to load the external swf files but they load in the same window. How can I load these .swf files in seperate window so that you could get back to the main window after you've finished watching?
    Here's my code:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        myLoader.load(myURL);
        addChild(myLoader);
    I'm also attaching screenshot with menu in flash

    I've deleted the line and now the code lookes like that:
    stop();
    var myLoader:Loader = new Loader();
    button1_btn.addEventListener(MouseEvent.CLICK, movie1_1);
    function movie1_1(e:MouseEvent):void
        var myURL:URLRequest = new URLRequest("01_01_Welcome.swf");
        addChild(myLoader);
    Unfortunately, it doesn't load the .swf file when you click on the button...

  • Loading external swf files in a swf - Error#1009

    I have been having trouble using a swf file within a swf file.   The external swf files all work as expected.  However when used within another swf file I get the standard TypeError #1009 for some of my swfs.   The external swf files are mainly actionscript 3 files.  A typical swf file will have an object (or objects) in the library which has an export for ActionScipt property enabled and an addEventListener(Event.ENTERFRAME, somefunction).   About four years ago when I had to do some work with AS2 I seemed to get around a similar issue with the _lockroot method but this is no longer part of AS3. I have searched various forums and note that I am not the only one with this issue but did not find any relevant solutions.   If anyone could give me any ideas on how to get around this it would be appreciated.
    Regards
    Norman

    Hi,
    I have added a download to rapidshare and its link is:
    Download link: http://rapidshare.com/files/380202712/ExtSwfs.zip
    The main file Training01.fla has been set up with links to download several swf's.   The links that do not work properly are those labelled :  Module6 and Module 8.   The first Module 6 connects to a function that is a variation of how I was trying to load external swfs using Application Domain, while Module 8 is a link to a swf that uses and external class.  Module 8 is supposed to load with rotating stars, while Module 6 loads the same file as the link called Module 1.   As soon as I use the two links Module 6 or Module 8 the whole lot ceases to work properly.  I did also follow through the examples on the Adobe site.  The examples for Module 6 and Module 8 are tutorials I have used from the Internet as part of my training from the site FlashMyMind.com but they replicate the type of work we have been doing with respect to using ActionScript3.
    Re my background, at this stage I am self-taught using tutorials on the web and whatever books I can lay my hands on here.  There is no structured training available where I live as there is insufficient demand and no books available on Flash or ActionScript at the local book stores or libraries so the books are ones I have ordered via the Internet.  The one I am currently using apart from Adobe Classroom in a Book Flash CS4 is O'Reilly's Learning ActionScript 3.0 a Beginners Guide.
    The other problem I have been trying to solve and still researching is why one loses sound in the flash player when playing flv files, if the user has selected or restarted a video (or videos) many times eg 25 to 30 times as we create video training files and serve them to the user within the flash environment using Flash Player 9 and IE6.
    Regards
    Norman

Maybe you are looking for

  • How to make my iphone stop asking for my friend's Apple ID?

    First question: why does apple website logs me out every minute saying "session time out" or something(i'm using chrome on iPad)..! Second Question: why after i typed such a big question and when i switch tab and come back to this tab, the tex disapp

  • What's wrong with my itunes and music?

    Hi all, After downloading Beyonce's full album to my itunes list, when ever I sync my phone, it doesn't sync my other artists and their songs? If I add new music to my itunes it wont allow me to transfer them onto my iphone 5 ! Please help

  • How do I get a Metalic look to a surface?

    I'm working on making a 3D logo for a client. They've generated a 3D image in Solidworks (Two letters of text). I import it into Photoshop and convert it to a psd and then into Shake for further processing as Photoshop won't let you apply filters to

  • MRP+Batch determination/restriction complex scenario

    I have a very complex issue with MRP and Batch Determination. Here is my situation. Please help me find a solution. I have materials which are batch managed and each material can have numerous batches based on the quality (80%, 70%, 90%). Materials c

  • Need to generate 2 idoc"mapping issue"

    Hi Experts, When the Purchase_order_type is coming like HIGH,REGULAR,NEW,BOUNCED. In this case i need to generate 2 idoc, based on HIGH is one and Other than HIGH is one, even though if it's REGULAR,NEW,BOUNCED. I can't generate. pl suggest rgds selv