Unloading loaded SWF classes

This is a fairly complicated issue so I'll try to explain it as best I can.
The first part is that I am downloading a SWF from a server that has a bunch of exported images in it. I am doing a lookup of the class names for these images then using that to load the data into the application. Later on down the line it is possible to download a separate SWF that has images in the same format with overlapping names.
The issue here is that when loading the second SWF with duplicate names it doesn't overwrite the data as one might expect, it uses whatever was loaded first. So I need to know if it's possible to either make it overwrite the classes with the new data or throw them away before loading the new SWF so the old ones don't get in the way. Is this possible at all? If not I suppose we could change the name of all of the assets so they are guaranteed to be unique but that would be a massive headache that I want to avoid at all costs.

I have my ways I'm Just looking up all of the available classes in the SWF and then getting the class data out of it and using that to load the images into the app.
EDIT: I sort of see what the problem is. The SWF files are being loaded into the same application domain so I assume that somehow limits loading multiple classes with the same name. So maybe I have to load each SWF into a new ApplicationDomain instead of using the main apps domain?

Similar Messages

  • Unloading Loaded SWF

    I have a movie/presentation that runs a simple navigation
    panel that loads in seperate SWF for each chapter.
    These run for apporixmately 3-4 mins each. With sound etc.
    They are published fine and that's working well. The problem I have
    is when they finish i want the movie to return to a main menu
    screen - also a seperate swf that loads up.
    Where do i put an unload or load separate movie script that
    won't attempt to load the main menu into the swf that is
    running?

    I have my ways I'm Just looking up all of the available classes in the SWF and then getting the class data out of it and using that to load the images into the app.
    EDIT: I sort of see what the problem is. The SWF files are being loaded into the same application domain so I assume that somehow limits loading multiple classes with the same name. So maybe I have to load each SWF into a new ApplicationDomain instead of using the main apps domain?

  • How to unload/load swf

    I have a Flash movie that automatically opens another Flash movie inside it. The main swf has a "Start" button at the bottom. When I click the Start button I want to unload the swf that loaded automatically (as a placeholder) and load a new Flash video swf. I'm doing this to create a placeholder for the video. I don't know what code I need to use on the button to unload the automatic swf and load the new swf video.

    if you don't need to stop any loaded streams (like sound/video), you can just reuse the same loader to load the next swf.  otherwise, apply unloadAndStop() to your loader before loading the next swf.

  • Loading SWFs: Classes do not match

    I've written an AIR app which loads coompiled SWFs and manipulates them.  The problem I've run into is that I cannot access the custom objects in the SWF because their class definition does not match the class definition in the AIR app.
    I have a library project that I develop all the classes in.
    The SWFs are published from Flash using the Source Path of this library, and the AIR app has the library project listed in its Build Path Libraries in FB 4.5.
    Example:  vManager is a ViewManager, a custom class used in the SWF to do various things.  It is accessible to the AIR runtime, but the AIR runtime thinks it's some other class that doesn't exist anymore:
    From the AIR runtime:
    trace(describeType(contentMC.vManager).toXMLString());
    <type name="gdit.controls::ViewManager" base="Object" isDynamic="false" isFinal="false" isStatic="false">
      <extendsClass type="Object"/>
      <constructor>
        <parameter index="1" type="flash.display::DisplayObjectContainer" optional="false"/>
      </constructor>
      <accessor name="state" access="writeonly" type="gdit.controls::ViewStateButton" declaredBy="gdit.controls::ViewManager"/>
      <accessor name="directiveText" access="writeonly" type="gdit.controls::IndexedTextField" declaredBy="gdit.controls::ViewManager"/>
      <accessor name="states" access="readonly" type="__AS3__.vec::Vector.&lt;gdit.controls::ViewStateButton>" declaredBy="gdit.controls::ViewManager"/>
      <method name="addViewState" declaredBy="gdit.controls::ViewManager" returnType="void">
        <parameter index="1" type="flash.display::Sprite" optional="false"/>
        <parameter index="2" type="Array" optional="false"/>
      </method>
      <method name="setDefaultViewState" declaredBy="gdit.controls::ViewManager" returnType="void">
        <parameter index="1" type="Array" optional="false"/>
      </method>
    </type>
    From the SWF:
    trace(describeType(vManager).toXMLString());
    <type name="gdit.controls::ViewManager" base="Object" isDynamic="false" isFinal="false" isStatic="false">
      <extendsClass type="Object"/>
      <constructor>
        <parameter index="1" type="flash.display::DisplayObjectContainer" optional="false"/>
      </constructor>
      <variable name="defState" type="String">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="527"/>
        </metadata>
      </variable>
      <accessor name="state" access="readwrite" type="gdit.controls::ViewStateButton" declaredBy="gdit.controls::ViewManager">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="2302"/>
        </metadata>
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="2378"/>
        </metadata>
      </accessor>
      <accessor name="defaultState" access="readonly" type="__AS3__.vec::Vector.&lt;flash.display::DisplayObject>" declaredBy="gdit.controls::ViewManager">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="577"/>
        </metadata>
      </accessor>
      <accessor name="states" access="readonly" type="__AS3__.vec::Vector.&lt;gdit.controls::ViewStateButton>" declaredBy="gdit.controls::ViewManager">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="694"/>
        </metadata>
      </accessor>
      <accessor name="directiveText" access="writeonly" type="gdit.controls::IndexedTextField" declaredBy="gdit.controls::ViewManager">
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="3075"/>
        </metadata>
      </accessor>
      <method name="addViewState" declaredBy="gdit.controls::ViewManager" returnType="void">
        <parameter index="1" type="flash.display::Sprite" optional="false"/>
        <parameter index="2" type="Array" optional="false"/>
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="1220"/>
        </metadata>
      </method>
      <method name="setDefaultViewState" declaredBy="gdit.controls::ViewManager" returnType="void">
        <parameter index="1" type="Array" optional="false"/>
        <metadata name="__go_to_definition_help">
          <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
          <arg key="pos" value="1577"/>
        </metadata>
      </method>
      <metadata name="__go_to_ctor_definition_help">
        <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
        <arg key="pos" value="793"/>
      </metadata>
      <metadata name="__go_to_definition_help">
        <arg key="file" value="G:\Flash\ASLib\src\gdit\controls\ViewManager.as"/>
        <arg key="pos" value="193"/>
      </metadata>
    </type>
    Both of these statements trace in  the AIR runtime.  Note that the SWF class is much larger:  this is because the AIR version is referencing a class definition that is roughly 4 versions old.
    I've tried wiping out the class def after publishing the SWF, and the AIR app still refers neither the current version of the class in the Library project, nor the version compiled in the SWF. 
    There are no errors or warnings in the Lib project, the main AIR project, or the SWF.  I've tried cleaning both projects, referencing the SWC directly, nothing seems to correct this issue.
    Maybe I'm integrating the library project incorrectly in FB?  I don't know, but if anyone does:  please let me know!
    Thanks

    Thanks for your response.
    I am still not clear. Print method is a implementation of the pageable interface why does PrintBlank implement Printable. what shows the print method is a implimentation of method of pageables Is the Print method part of class PrintBlank . I see that it is outside of the brackets of PrintBlank .
    also is the order of process class PrintBlank calls PrintJob's print method this does not take any paramters.
    PrintJob then calls Pageable's print method which sends the parameters Graphics g, PageFormat format and int pageIndex.
    Thanks

  • Using TextSnapshot class on a loaded SWF on an iPad

    Hello, I am creating an iPad app. I am loading SWF files using a Loader object, then placing them in a movieclip and setting a SWFLoaders source property to this clip. Before I add the clip to the SWFLoader control I am using the TextSnapshot class on it, to retrieve an array with the getTextRunInfo method.
    All this works fine when I test it on my desktop machine. However, on the iPad it causes the app to crash when a control using this clip is added to the stage. Can you still use TextSnapshot with an iPad, is there a workaround for this? Thanks for your help.

    We are a university. most of our books are SWF files. We have been using iPad/FlexBuilder 4.5 to successfully view the contents of these books.
    All navigation (i.e gotoandstop(page), etc work fine. Gestures for pageforward/pageback, zoom, pan work fine also.
    Not sure I understand your comment.
    However, there IS a specific problem with text snapshot. Below is a short code piece used to highlight text on a page.
    If you remove the failing line everything works fine.
    If you "debug" the iPad device everything works fine when you execute the code on the iPad
    if you create a release build, when the application starts and the "findtext" line is executed the "app" freezes. No error message. The try/catch does not seem to catch any error.
    This is something we really need for our app. If this is a bug how should we report it.
    Thanks for your help.
      public function highlightText(txt:String):void {
       var start_pos:int = 0;
       try {
        if (txt == null || txt.length == 0) { return; }
        infoMessage("highlightText: " + txt);
        allText = _libMC.textSnapshot;      
        allTexts.push(allText);  // no reason for this but must do to make work 
        start_pos = allText.findText(start_pos, txt, false);     <<<<<< Failing line ====================================
        infoMessage("start_pos: " + start_pos);
       catch (err:Error) {
        infoMessage("error: " + err.message);   
       finally {
        infoMessage("finally");

  • How to unload externally loaded swf which contains 3D Carousel?

    Hello to all
    I am learning AS3 and have been taking on various tutorials found on the net. While learning about AS3 I came across a lesson on http://tutorials.flashmymind.com/2009/05/vertical-3d-carousel-with-actionscript-3-and-xml/ titled "Vertical 3D Carousel with AS3 and XML".
    I completed the tutorial and all worked fine so I then wanted to load the swf into a existing project. The loading of the swf goes fine and when I unload my loader it is removed but only visually as in my output panel in flash CS5 I get an error as follows
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at carousel_c_fla::MainTimeline/moveCarousel()
    this error repeats over and over again slowing my swf movie.
    So does this mean my main flash movie trying to still play / find my unloaded 3D Carousel?
    If so how do I unload remove all the AS3 that is trying to run from the 3D Carousel?
    I have included the AS3 below from the tutorial page and I understand that this is what I have to remove to "break free" from the 3D Carousel swf when it is unloaded. This is where I am stuck as my knowledge of AS3 is limited - Can you guys / girls help?
    //Import TweenMax
    import com.greensock.*;
    //The path to the XML file (use your own here)
    // old var from tutorial - var xmlPath:String = "http://tutorials.flashmymind.com/XML/carousel-menu.xml";
    var xmlPath:String = "carousel-menu.xml";
    //We'll store the loaded XML to this variable
    var xml:XML;
    //Create a loader and load the XML. Call the function "xmlLoaded" when done.
    var loader = new URLLoader();
    loader.load(new URLRequest(xmlPath));
    loader.addEventListener(Event.COMPLETE, xmlLoaded);
    //This function is called when the XML file is loaded
    function xmlLoaded(e:Event):void {
         //Make sure that we are not working with a null variable
         if ((e.target as URLLoader) != null ) {
              //Create a new XML object with the loaded XML data
              xml = new XML(loader.data);
              //Call the function that creates the menu
              createMenu();
    //We need to know how many items we have on the stage
    var numberOfItems:uint = 0;
    //This array will contain all the menu items
    var menuItems:Array = new Array();
    //Set the focal length
    var focalLength:Number = 350;
    //Set the vanishing point
    var vanishingPointX:Number = stage.stageWidth / 2;
    var vanishingPointY:Number = stage.stageHeight / 2;
    //We calculate the angleSpeed in the ENTER_FRAME listener
    var angleSpeed:Number = 0;
    //Radius of the circle
    var radius:Number = 128;
    //This function creates the menu
    function createMenu():void {
         //Get the number of menu items we will have
         numberOfItems = xml.items.item.length();
         //Calculate the angle difference between the menu items (in radians)
         var angleDifference:Number = Math.PI * (360 / numberOfItems) / 180;
         //We use a counter so we know how many menu items have been created
         var count:uint = 0;
         //Loop through all the <button></button> nodes in the XML
         for each (var item:XML in xml.items.item) {
              //Create a new menu item
              var menuItem:MenuItem = new MenuItem();
              //Calculate the starting angle for the menu item
              var startingAngle:Number = angleDifference * count;
              //Set a "currentAngle" attribute for the menu item
              menuItem.currentAngle = startingAngle;
              //Position the menu item
              menuItem.xpos3D = 0;
              menuItem.ypos3D = radius * Math.sin(startingAngle);
              menuItem.zpos3D = radius * Math.cos(startingAngle);
              //Calculate the scale ratio for the menu item (the further the item -> the smaller the scale ratio)
              var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
              //Scale the menu item according to the scale ratio
              menuItem.scaleX = menuItem.scaleY = scaleRatio;
              //Position the menu item to the stage (from 3D to 2D coordinates)
              menuItem.x = vanishingPointX + menuItem.xpos3D * scaleRatio;
              menuItem.y = vanishingPointY + menuItem.ypos3D * scaleRatio;
              //Add a text to the menu item
              menuItem.menuText.text = item.label;
              //Add a "linkTo" variable for the URL
              menuItem.linkTo = item.linkTo;
              //We don't want the text field to catch mouse events
              menuItem.mouseChildren = false;
              //Assign MOUSE_OVER, MOUSE_OUT and CLICK listeners for the menu item
              menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
              menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem);
              menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
              //Add the menu item to the menu items array
              menuItems.push(menuItem);
              //Add the menu item to the stage
              addChild(menuItem);
              //Assign an initial alpha
              menuItem.alpha = 0.3;
              //Add some blur to the item
              TweenMax.to(menuItem,0, {blurFilter:{blurX:1, blurY:1}});
              //Update the count
              count++;
    //Add an ENTER_FRAME listener for the animation
    addEventListener(Event.ENTER_FRAME, moveCarousel);
    //This function is called in each frame
    function moveCarousel(e:Event):void {
         //Calculate the angle speed according to mouseY position
         angleSpeed = (mouseY - stage.stageHeight / 2) * 0.0002;
         //Loop through the menu items
         for (var i:uint = 0; i < menuItems.length; i++) {
              //Store the menu item to a local variable
              var menuItem:MenuItem = menuItems[i] as MenuItem;
              //Update the current angle of the item
              menuItem.currentAngle += angleSpeed;
              //Calculate a scale ratio
              var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);
              //Scale the item according to the scale ratio
              menuItem.scaleX=menuItem.scaleY=scaleRatio;
              //Set new 3D coordinates
              menuItem.xpos3D=0;
              menuItem.ypos3D=radius*Math.sin(menuItem.currentAngle);
              menuItem.zpos3D=radius*Math.cos(menuItem.currentAngle);
              //Update the item's coordinates.
              menuItem.x=vanishingPointX+menuItem.xpos3D*scaleRatio;
              menuItem.y=vanishingPointY+menuItem.ypos3D*scaleRatio;
         //Call the function that sorts the items so they overlap each other correctly
         sortZ();
    //This function sorts the items so they overlap each other correctly
    function sortZ():void {
         //Sort the array so that the item which has the highest
         //z position (= furthest away) is first in the array
         menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
         //Set new child indexes for the item
         for (var i:uint = 0; i < menuItems.length; i++) {
              setChildIndex(menuItems[i], i);
    //This function is called when a mouse is over an item
    function mouseOverItem(e:Event):void {
         //Tween the item's properties
         TweenMax.to(e.target, 0.1, {alpha: 1, glowFilter:{color:0xffffff, alpha:1, blurX:60, blurY:60},blurFilter:{blurX:0, blurY:0}});
    //This function is called when a mouse is out of an item
    function mouseOutItem(e:Event):void {
         //Tween the item's properties
         TweenMax.to(e.target, 1, {alpha: 0.3, glowFilter:{color:0xffffff, alpha:1, blurX:0, blurY:0},blurFilter:{blurX:1, blurY:1}});
    //This function is called when an item is clicked
    function itemClicked(e:Event):void {
         //Navigate to the URL that's assigned to the menu item
         var urlRequest:URLRequest=new URLRequest(e.target.linkTo);
         navigateToURL(urlRequest);

    Hi Ned thanks for the reply,
    Ok so I have a button in my main movie that loads the external swf
    stop();
    var my_loader:Loader = new Loader();
    var my_btn:Button = new Button();
    var my_pb:ProgressBar = new ProgressBar();
    my_pb.source = my_loader.contentLoaderInfo;
    my_btn.addEventListener(MouseEvent.CLICK,startLoading);
    function startLoading(e:MouseEvent):void{
    my_loader.load(new URLRequest("carousel.swf"));
    addChild(my_pb);
    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishloading);
    function finishloading(e:Event):void{
    addChild(my_loader);
    my_loader.addEventListener("killMe",
    killLoadedClip);
    removeChild(my_pb);
    function killLoadedClip(e:Event):void {
    my_loader.removeEventListener("killMe",
    killLoadedClip);
    my_loader.unloadAndStop();
    removeChild(my_loader);
    Then I have a button in my loaded swf that closes the loader
    This is spread over 2 frames
    Frame1
    function closeIt(e:MouseEvent):void {
    parent.dispatchEvent(newEvent("killMe"));
    Frame 2
    back_btn.addEventListener(MouseEvent.CLICK, closeIt);
    Frame 2 also holds all the code for the carousel
    Thanks for your time and help in advance people ; )

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

  • Pass parameters to a function in main class from loaded SWF?

    I've got a main.as that loads SWF to the stage.
    the loaded SWF seppoused to pass a link to the main.as and trigger a javascript function to popUp that photo from that link.
    I know there are two ways:
    ((root as MovieClip).parent.parent as Object).somefunction(parameters);
    and to dispatch an event.
    inorder to pass parameters throug the event i need to extend it with another class.
    isnt the (root as... )  more efficient if all i need is to pass a link?

    when a photo from the gallery is selected a javascript popUp shows it enlarged with additioan editing options (kinda like in facebook).
    in that popUp ther is also a next button so its kinda bidirectional. (the next calling the loaded SWF throug main to get the next link in the photo array)
    the photo is a grandchild of a grandchild of the stage and the loaded swf is a grandchild so using:
    ((root as MovieClip).root as MovieClip).ExternalInterface.call("ShowPic", link);
    is discusting ><

  • Can button in loaded SWF file unload or close the file ?

    Hi,
    I am loading 2 SWF files A and B, I have a button on each.
    When I press button on SWF A it loads SWF B. However I cannot get
    the button to close / unload the SWF A.
    Is this possible ?
    To Load I am using:
    Thanks,
    Paul

    No.I am using Loader since I dont need to pass one URL for fetching swf content.I need to get the displayobject from ByteArray which should be free from all the security issues.I heard that we cannot set 'securityDomain' property of loaderContext (using in Loader) in AIR.So please give a solution for getting bytes.

  • Loading/Unloading a .swf that adds event listeners to the Stage

    Hi all,
    Disclaimer
    Apologies if I suck so bad at using forum search that the answer to this is on page 1 somewhere; I tried...
    Question
    I am loading and unloading a .swf to which I do not have source code access. This .swf places several event listeners on the stage, as far as I can tell. When the .swf is unloaded, the event listeners placed upon the stage still seem to be in effect. Using unloadAndStop doesn't seem to do it, and I have to target Flash Player 9, anyway, so can't really use it. Is there any other way I can keep this external .swf from holding onto my main movie's stage?
    Additional info
    All eventListeners and references being set by my code are removed.
    I've managed a little contact with the author of the .swf:
    I've requested he provide a dispose() method I can call to get all the listeners removed, and send an updated .swf.
    He's suggested that I should be able to avoid the problem by loading into a unique ApplicationDomain. I'm not terribly familiar with this, but have given it a try without much success. Is this a valid solution - can I really protect my 'stage' by properly using ApplicationDomains - or do I need to persist in trying to get a public dispose() method built in?
    Thanks in advance!
    Cheers, John

    thanks for reply sir
    sir actually, i have not any problem with loading any file but i need to go back to intro.swf file when i click on clsbtn of main.swf, i want unload the main.swf file and panel.swf file
    actually i did was, i have intro.swf file and there is button by clicking load main.swf file (where is timeline controling butons) and in the main file automatically load panel.swf file ( where is all animation)
    its all play gud , no problem
    but my problem is there is a clsbtn in main.swf file and when i click on that button everything should be unload and it should return on the previous position in intro.swf
    i hope u understand what i am trying to say

  • Invoking class from loaded swf

    I'm working on a project where I'm loading in a video player
    as an external swf to my main movie. I'm not able to get my video
    or the custom player to show up, but sound is there (I've done the
    whole Library>New Video thing, so I have a video object to
    reference).
    My question is: My loaded swf uses #include to include a
    script which imports two classes from a subdirectory, could that be
    causing the problem? My main movie never uses the classes.
    Just want to make sure this isn't my problem before I go
    digging into the script again!

    That is unlikely to be the problem. The .as includes are
    compiled into the
    SWF at publish. Much more likely is that you have
    inappropriate references
    to _root in your loaded movie. As it stands, the scope of
    _root, once you
    load the movie into another, is the _root of the *loading*
    movie. Either
    change these refs, or set the _lockroot property of the mc
    you are loading
    into to true.,
    Remove '_spamkiller_' to mail

  • Access the property of main class in loaded swf.

    Hi
    i have one main.fla, its document class is main.as. the code in main.as is
    package
    import flash.display.MovieClip;
    public class Main extends MovieClip
    private var loading:Loading;
    public var trovami:Number=10;
    public function Main()
    stage.frameRate=31;
    loadSWF();
    private function loadSWF():void
    loading=new Loading(this);
    Loadind.as is another class where i load another swf its name is my_swf.
    the code of loading class is:
    package
    import flash.display.MovieClip;
    import flash.display.SimpleButton;
    import flash.text.TextField;
    import flash.display.Loader;
    import flash.events.*;
    import flash.net.URLRequest;
    public class Loading extends MovieClip
    private var _fla:MovieClip;
    private var url:String;
    public var val:String;
    private var loader:Loader;
    public function Loading(fla:MovieClip)
    _fla=fla;
    init();
    private function init():void
    url='my_swf.swf';
    var request:URLRequest=new URLRequest(url);
    loader=new Loader();
    initListeners(loader.contentLoaderInfo);
    loader.load(request);
    private function initListeners(dispatcher:IEventDispatcher):void
    dispatcher.addEventListener(Event.COMPLETE,completato);
    private function completato(event:Event):void
    _fla.addChild(loader);
    loader.y=10;
    val="hello"
    and the document class of loaded swf is Main2. in my_swf.fla there is one text its name is:
    a_txt.
    so i have to use property of Loading class in Main2 for text.
    code of Main.as is
    package
    import flash.display.MovieClip;
    import flash.text.*;
    public class Main2 extends MovieClip
    public function Main2()
    a_txt.text=val;
    where val is the property of Loading class.
    so how can i access.

    You have a reference to your loaded movie within your Loading class - instead of just setting val to a string - add a method in your Main2 class - and call that from Loading - passing the string to it. Push not pull...
    Main 2 becomes:
    public function Main2() {
         //a_txt.text=val;
    public function setText(val:String):void {
        a_txt.text = val;
    And then in your Loading class - when you're done loading just call setText:
    private function completato(e:Event):void
        addChild(loader);
        loader.y=10;
        MovieClip(loader.content).setText("hello");
        //val="hello";

  • Load/ Unload external .swf

    ----------------------------------------
    vita | web | design | illustration
    "main" here
    I try to have external .swf on this "main" part of my flash
    design automatically using load actionscript.
    I have 3 different sets of actionscripts for load/unload.
    But, the problem is when I click vita or other menu on the
    top after loading "main" external .swf, they are overlapped.
    How can I unload the external .swf from the automatically
    loaded .swf?
    (As I know, there are mostly buttons to click on loading
    external .swf. But for my design, I want it loads automatically.)
    Thanks in advance for suggestions. Please let me know if my
    description/question is not clear to answer.

    Are you using AS2 or AS3. The approach is completely
    different for both.

  • Accessing a class from a loaded SWF

    In Flash Professional, I drew a shape, converted it to symbol, linked it to class Symbol1 (extends MovieClip) which is generated at run-time, and saved the SWF file as shape.swf.
    Now my main application wants to load shape.swf and create multiple instances of Symbol1 but I get ReferenceError when trying to access the class Symbol1.
    Below is my main application's code. Errors thrown are mentioned in comments.
    public class MovieClipTest extends Sprite
        public function MovieClipTest()
            var url:String = 'shapes.swf';
            var l:Loader = new Loader();
            l.contentLoaderInfo.addEventListener(Event.COMPLETE, f);
            l.load(new URLRequest(url), new LoaderContext(false, ApplicationDomain.currentDomain));
        private function f(event:Event):void
            var content:Sprite = (event.currentTarget as LoaderInfo).content as Sprite;
            trace(getQualifiedClassName(content.getChildAt(0))); // output: Symbol1
            trace(ApplicationDomain.currentDomain.getDefinition('Symbol1')); // throws Error #1065: Variable Symbol1 is not defined.
            trace(getDefinitionByName('Symbol1')); // throws Error #1065: Variable Symbol1 is not defined.

    Your "Symbol" is obviously not in the current ApplicationDomain, but in the loaded SWF's domain:
    var symbolClass:Class = event.target.applicationDomain.getDefinition("Symbol") as Class;
    var symbolInstance:MovieClip = new symbolClass() as MovieClip;
    Also because you're loading a SWF, the content of the Loader is a MovieClip, not a Sprite.
    Kenneth Kawamoto
    http://www.materiaprima.co.uk/

  • How to load and unload external .swfs in a main .fla then load another external .swf on top

    I know that the question sounds confusing. I am new to AS3 but a little dangerous with it.
    The project
    I'm putting together a website tour with has a main .fla with navigation buttons. The navigation buttons load external .swfs using X and Y properties. Every external .swf houses a scrubber bar, play pause buttons which calls to a movie clip which houses the animation.
    The problem:
    Everything was working great, until someone mentioned "Hey, what if at the end of each loaded external .swf, a button appears that says "go to next section".
    So basically we are trying to give the user another way to get to the next section in the left hand navigation once the animation ends, in addition to being able to click in the left hand navigation for the next section. It's kind of like when a youTube video ends and it displays a button to go to the next movie that's in line, but you can also do it in the thumnail navigation as well.
    Ok, let's try it. Well, after many nights, searching the web and trying everything I am waving the white flag. I went through the lynda.com book over and over but I get an error message when I add code related to the parent timeline. I can actually get the next section to load on top of the previously loaded .swf, but it's buggy and I think the previous section is showing through underneath. Plus the scrubber isn't really working right. Since every .swf has a scrubber to control it, shouldn't it just load on top of the previous .swf? Do I need to add coding related to the parent timeline?
    I don't know if I should paste my code here, I have a sample .fla too. Help is so greatly appreciated!!!! If this can work, I think it would be very useful for anyone else doing something like this - I would definitely share any knowledge gained!
    Thanks.
    Jen

    If you want to utilize that code as a starting point (hopefully you understand what it does, and that the code actually works), then you need to modify it such that the array at the start has your filenames instead of the three it now shows, and the three buttons it uses are changed to the next and previous buttons you intend to use.  Here are the functions you need to make adjustments to...
    function onCompletePreloading():void {
            _loadedSWFs = 0;
            contentContainer.addChild(_swfClipsArr[_loadedSWFs]);
            next_btn.addEventListener(MouseEvent.CLICK, setContent);
            prev_btn.addEventListener(MouseEvent.CLICK, setContent);
    function setContent(event:MouseEvent):void {
            var _swfToAdd:MovieClip;
            if(event.currentTarget.name == "next_btn") {
                _loadedSWFs += 1;
                if(_loadedSWFs == _swfClipsArr.length){
                       _loadedSWFs = 0;
            } else if(event.currentTarget.name == "prev_btn"){
                _loadedSWFs -= 1;
                if(_loadedSWFs == -1){
                       _loadedSWFs = _swfClipsArr.length-1;
            _swfToAdd = _swfClipsArr[_loadedSWFs];
            contentContainer.removeChildAt(contentContainer.numChildren-1);
            contentContainer.addChild(_swfToAdd);
            trace(_swfToAdd.customID);

Maybe you are looking for

  • HOW TO HANDLE PR / PO SCENARION

    Hi Gurus, In our case user create Po with reference to PR manually. But suppose user gives PR for say mat X, qty 10, & purchase user creates PO for that mat. X but qty say 100 (open PO)for his convienience. So when GR is done, its done for 10 qty onl

  • IPTables blocking NetBIOS

    I have had this problem for a while now and I have finally decided to fix it once and for all. I am unable to connect to the shared folders of other computers on the local network. Running smbclient with results in NT_STATUS_UNSUCCESSFUL but if I con

  • How to maintain format in html email using the send email....

    Does anyone know how to maintain the format in a HTML email using the Send E-mail To Recipients From Recordset behavior? When text only is selected instead of HTML text on the Options tab the format of the input is maintained, but when HTML text is s

  • DISTINCT in SELECT statements for  Entities / Views - Oracle JDeveloper 11G

    Hi Steve, i have a question about using DISTINCT in SELECT statements for Entities / Views. On Oracle JDeveloper 11G ADF / BC4J --- This is unique--- SELECT distinct(GC."course_title"), GC.SEC_GRP_PARENT_ID, from "grp_courses" GC --- This is NOT uniq

  • Monitor Oracle E-Business Suite R12.1.2

    Dear all, can someone help me to configure dmstool for Oracle ebs 12.1.2 to monitor the processes. Thanks in advance. Regards, Anoep