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

Similar Messages

  • 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

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

  • Trying to properly code a menu with buttons that can go back and forth between external swf files

    I have a project I've been working on that, when properly coded, has a "main menu" with 4 "doors" (buttons). When the corresponding buttons to these "doors" are clicked, it should go to and play an external .swf file. If that doesn't make sense, think of a DVD menu. You click play movie, it plays the movie. When the movie is over, there's two buttons on that swf file to either play the movie over or go back the main menu, which is an external .swf file (Remember, we go to the movie from the menu, which is a seperate file). So far, the buttons work. The menu works. However, from the movie, at the conclusion, when I click the button to go back to the main menu, it displays the movie clip and the buttons, but none of the buttons work. I'm starting to think it has to do with the fact the main menu was written in AS3 and the movie was made in AS2. If anyone can assist me in being to able to keep both files and still navigate between the two, being able to bring up the menu from the movie and be able to play the movie again, and so on and so on, that'd be GREAT. I'm somewhat of a noob to Flash, but I learn quickly and I'm open to any suggestions. Here's the code for main menu, which I guess acts as the parent file, and the movie. If I get this to work, I essentially would duplicate the same actions for the other 4 doors, once I complete the environments for them. Thanks
    Main.Fla/Swf (written in AS3)
    (This is the action on the first frame, that has all the buttons. For this question, I'm just trying to properly code for 'Door4', which is the "door" to the movie.)
    import flash.display.Loader;
    stop();
    var myLoader1:Loader=new Loader ();
    Door4.addEventListener(MouseEvent.CLICK, jayzSwf);
    function jayzSwf(myevent1:MouseEvent):void
              var myURL1:URLRequest = new URLRequest("jayzspeaks.swf");
              myLoader1.load(myURL1);
              addChild(myLoader1);
              myLoader1.x = 0;
              myLoader1.y = 0;
    Movie.Fla/Swf (written in AS2)
    (This is action on the button that returns to the menu)
    on (release) {
              this.createEmptyMovieClip("container",this.getNextHighestDepth());
              container.loadMovie("main.swf");

    At least you're going in the correct (mis)direction. You have AS3 loading AS2. So that's not a huge hurdle.
    I believe all you really need to do is send your Main.swf a signal that the content it loaded (e.g. jayzspeaks.swf) is done and you want to get rid of it.
    The code I pointed you to asks you to (upon download and import then) instantiate it in both AS2 and AS3. They give a very simple easy to understand line of code.
    // as2, load this in jayzspeaks.swf
    var myBridge:SWFBridgeAS2 = new SWFBridgeAS2("connectionID", clientObj);
    // as3, load this in main.swf
    var myBridge:SWFBridgeAS3 = new SWFBridgeAS3("connectionID", clientObj);
    Make sure the connectionID matches between them. Set it to whatever you want.
    When you're done with your as2 loaded content you'd send a signal (over localconnection) back to the AS3 Main like they say:
    myBridge.send("someFunctionToUnloadContent");
    myBridge.close();
    You'd need to make the as3 function "someFunctionToUnloadContent()" (example purposes only name) and it should unload the jayzspeaks.swf that was loaded in the loader.
    Make sure you get that close in there so you don't drill up a bunch of localconnection objects just like the simple source code says.

  • The external GPS is used only for 911 but the device will not op without it...this causes great inconvenience for me, having to run that cable to a window in the trwo houses I use it..ids there a way to disable the GPS if I do not care about the 911 funct

    the external GPS is used only for 911 but the device will not operate without it...this causes great inconvenience for me, having to run that cable to a window in the two houses I use it..is there a way to disable the GPS if I do not care about the 911 functionability..?  this is the only downside I have with the network extender and it renders my device useless..

    Nope, GPS is a Federal requirement for anything operating a cellular telephone signal.  You don't ever plan to call 911 until you are in an emergency.  I don't see that requirement changing any time soon.
    If you are truly inconvenienced by the VZW network extender then perhaps you should disable you calling features in these areas and swap over to WiFi only.  There are many services and apps out there that can route your phone services through internet service providers. 

  • HT201412 while using sometimes my iphone 5stops working and shows the apple logo with white background for 5 seconds and in short time it returns to home screen.please solve it

    while using sometimes my iphone 5stops working and shows the apple logo with white background for 5 seconds and in short time it returns to home screen.please solve it

    Hi there bencong111,
    You may find the troubleshooting steps in the article below helpful.
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    -Griff W. 

  • 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

  • Concern in published SWF file using Presenter for PPTX

    I observed that the PPT files (2003 version) which were published using Presenter 7 were creating a SWF file containing multiple frames. However the PPTX files (2007) which were published using Presenter 7 were creating a SWF file containing single frame. I am wondering how do I access a movieclip containing an animation.

    Let me re-phrase.
    I am loading the Presenter SWF into my Flash file (controller). Once the file is loaded I am controlling that file; I mean to say, I play/pause or jump to particular frame using the Flash file (Controller). This was working fine when I published PPT files, however when I published the PPTX file I am not getting the expected timeline animation so as to control it.
    Now I am wondering how I can control the PPTX published file using my controller.
    I will grateful, if someone helps me to solve this issue.

  • Loading class from an external .swf file

    Hi,
    My flash application has lots of resources which will change all the time. In order to keep the the user from having to download my main .swf file over and over again, and in order to keep the main file's size low, I would like to put the resources into separate .swf files and load them dynamically from a url using a Loader.
    Once downloaded I would like to extract the classes that are in the resource swf and use them in the main swf. Can anyone share some code for doing this? Note that I am not just interested in using a symbol from the resource swf. I would like to use a class, with all of its methods and everything, and my main swf does not contain the class definition. Only the resource swf does.
    Thanks!!

    This is a great question for flash programming.
    And when you know the answer to this, you are likely to use it on daily basis like the top level programmers  of an agency.
    ApplicationDomain is your answer and the adobe docs has a chapter on this.
    ApplicationDomain is where all of your classes will be loaded into and when you use a loader you have the ability to target this with the laoderContext.
    AplicationDomain.currentDomain loads all classes into the main app and if your main app already has these classes, then the app uses the parents classes
    new Application.Domain() specifies a seperate repo of classes that are loaded in so that classes in the main app will not be confused by the classes in a loaded swf. that refer to the same names.
    this locks down the communication between the swfs but will use the newer updated classes on the child when a child is loaded in with the same class names as the parents.
    new ApplicationDomain(currentDomain)  will enclose a new repo with the parent repo of the class definitions.

  • 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

  • I just purchased Adobe Photoshop Elements 13 online... and the d/l options are only for Windows 7 and 8 and I am still using Vista

    Please give me detailed instructions if possible

    Photoshop Elements 13 only runs on Windows 7 and 8. It will not install or run on Vista.
    System requirements | Adobe Photoshop Elements

  • After downloading and installing the 64-bit version of iTunes for Windows I get a "Congratulations, you've successfully installed iTunes" message. However, when I plug in my iPhone to synch it I get a message that says that I don't the 64-bit version??

    After downloading the 64-bit version of iTunes on my Windows 7 machine I get the "Congratulations, you've successfully installed iTunes" message.  However, when I plug in my iPhone I get an error message that says, in part, "...the required software is not installed.  Run the installer to remove iTunes, then install the 64-bit version of iTunes".  I've been at this for hours, carefully deleting all Apple software (Apple Mobile Support, Quicktime, etc. and before each attempt to install the 64-bit version from Apple ( no third parties).  Same result each time!!!  Any ideas????

    Let's try a standalone Apple Mobile Device Support install. It still might not install, but fingers crossed any error messages will give us a better idea of the underlying cause of why it's not installing under normal conditions.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/
    Right-click the iTunesSetup.exe (or iTunes64setup.exe), and select "Extract to iTunesSetup" (or "Extract to iTunes64Setup"). WinRAR will expand the contents of the file into a folder called "iTunesSetup" (or "iTunes64Setup").
    Go into the folder and doubleclick the AppleMobileDeviceSupport.msi (or AppleMobileDeviceSupport64.msi) to do a standalone AMDS install.
    (If it offers you the choice to remove or repair, choose "Remove", and if the uninstall goes through successfully, see if you can reinstall by doubleclicking the AppleMobileDeviceSupport.msi again.)
    Does it install (or uninstall and then reinstall) properly for you? If so, does your device connect without that message now?

  • My ipod 4 wont let me get certain apps like kik call of duty and vine the free buttons are blurred out for these apps and more

    I seriously really want these apps but it wont let me and I am old enough to get the apps! Please help me soon.

    Do you have a Restrictions set that prevent installing those apps? Go to Settings>General>Restrictions and check.
    Vine requires iOS 5 or later but y have to 17 years old. The age is determined by Restrictions, not the Apple ID used.

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

  • Loading external SWF fila and accessing variables/functions

    Hello everybody!
    My first post here. Actually I do search google for answers all the time, but now - it's tough one.
    public function loadScreen(swf:File):void {
         _content = swf;
         var swfBytes:ByteArray = new ByteArray();
         var file:File = _content;  
         var loadStream:FileStream = new FileStream();
              loadStream.open( file, FileMode.READ );
              loadStream.readBytes( swfBytes );
              loadStream.close();
         var loader:Loader = new Loader();
         var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
              loaderContext.allowLoadBytesCodeExecution = true;
              loader.loadBytes( swfBytes, loaderContext);
              loader.contentLoaderInfo.addEventListener(Event.INIT, accessSWF);
              loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
    public function errorHandler(e:Event):void {
         trace("PROBLEM LOADING BYTES");
    public function accessSWF(e:Event):void {
         var moduleLoader:LoaderInfo = LoaderInfo(e.target);
         moduleLoader.content.addEventListener(Event.INIT, readyHandler);
    public function readyHandler(e:Event):void {
         _initOptions = new NativeWindowInitOptions();
         with(_initOptions) {
              resizable = true;
              transparent = false;
         var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
         _window = new NativeWindow(_initOptions);
         with(_window) {
              activate();
              bounds = boundsWin;
              stage.scaleMode = "noScale";
    The problem is that application loads the external swf with loadBytes, but it's not executing the script. Actually, I'm not able to use the loaded swf. I'm not able even to add it to Stage. But message in output still shows, that the swf file is loaded "[SWF] file.swf/[[DYNAMIC]]/1 - 2746 bytes after decompression"
    There are many solutions for this problem on the internet, but they're old (written in 2008 most of all) and not working either, because those solutions work only in older AIR versions
    Any help?

    Well I got a bit further:
    public function loadScreen(swf:File):void {
         var loadStream:FileStream = new FileStream();
         with(loadStream) {
              openAsync( swf, FileMode.READ );
              addEventListener(ProgressEvent.PROGRESS, loadProgress);
              addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
              addEventListener(Event.COMPLETE, loadComplete);
    public function loadProgress(e:ProgressEvent):void {
         trace("Loading " + e.target.bytesAvailable);
    public function errorHandler(e:IOErrorEvent):void {
         trace("Error ");
    public function loadComplete(e:Event):void {
         var swfBytes:ByteArray = new ByteArray();
         FileStream(e.target).readBytes( swfBytes );
         var loaderContext:LoaderContext = new LoaderContext();
         with(loaderContext) {
              allowLoadBytesCodeExecution = true;
         var loader:Loader = new Loader();
         with(loader) {
              loadBytes( swfBytes, loaderContext);
              contentLoaderInfo.addEventListener(Event.INIT, completedSWF);
    public function completedSWF(e:Event):void {
         var moduleLoader:LoaderInfo = LoaderInfo(e.target);
         moduleLoader.addEventListener(Event.COMPLETE, initiatedFinally);
    public function initiatedFinally(e:Event):void {
         _initOptions = new NativeWindowInitOptions();
         with(_initOptions) {
              resizable = true;
              transparent = false;
         var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
         _window = new NativeWindow(_initOptions);
         with(_window) {
              activate();
              bounds = boundsWin;
              stage.scaleMode = "noScale";
         var loader:Loader = e.target.loader;
         loader.addEventListener(Event.ADDED_TO_STAGE, irAdded);
         _window.stage.addChild(loader);
    public function irAdded(e:Event):void {
         trace(e.target.content.vars); // Object Dictionary
    At this point ( function irAdded ) I'm able to retrieve external SWF's variables. But stil, it's not visible on the stage. And yet - there's another problem - rendering the same script , every second time application unloads the external swf movie.

Maybe you are looking for

  • Problem with hp

    Our office recently switched to windows 7 from xp.  My printer is hp office jet pro 8500.  I can print word documents but not excel spreadsheets.  It keeps saying its out of memory,  even if I tell it to print highlighted selection or page 1 of 1.  V

  • How do you get your IPHONE 4 off of earphone mode?

    I can't hear anything when I call people.  I have never used ear phones so I don't know how my phone got stuck in headset mode.  Can anyone help me get it out on this mode?  Thanks!!

  • Flip4Mac and how to use it

    I recently downloaded it with a view to using WMP content but on clicking the green WMV icon nothing happens, so i am not sure how it works. I tried to download WMP 9 for Mac and all that happens is that iMovies opens when the download completes?? An

  • BLOB with Form6i

    With the Form6i, I create a form in which one of the items is with type IMAGE. With this IMAGE item, I add a trigger for WHEN_IMAGE_PRESSED as below. read_image_file(get_file_name(),'TIFF','s_image.image'); If the data type of "s_image.image" is LONG

  • RMI: Is it the right choice?

    I want to make an application that connects to 1 other peer. So I'd run the application and if I type in the IP of someone else running the same application, we can connect to each other and do stuff like chatting. Is RMI the right choice to make thi