Load swf via Actionscript 2.0

I use Actionscript 2.0 to load an external swf [shared
directory], followed 2 similar tutorials [1 from LiveDocs, the
other from Flash 8 ActionScript Bible] neither works. Here is the
code, if someone sees whatI'm missing I'd appreciate the
assistance:
this.createEmptyMovieClip("myswf.swf", 999);
var site_mc:MovieClipLoader = new MovieClipLoader();
// Create listener object:
var mclListener:Object = new Object();
mclListener.onLoadError = function(target_mc:MovieClip,
errorCode:String, status:Number) {
trace("Error loading movie clip: " + errorCode + " [ " +
status + "]");
mclListener.onLoadStart = function(target_mc:MovieClip) :Void
trace("onLoadStart: " + target_mc);
mclListener.onLoadProgress = function(target_mc:MovieClip,
numBytesLoaded:Number, numBytesTotal:Number) :Void {
var numPercentLoaded:Number = numBytesLoaded / numBytesTotal
* 100;
trace("onLoadProgress: " + target_mc + " is " +
numPercentLoaded + "% loaded");
mclListener.onLoadComplete = function(target_mc:MovieClip,
status:Number) :Void {
trace("onLoadComplete: " + target_mc);
my_mcl.addListener(mclListener);
my_mcl.loadClip("myswf.swf");

Hi,
you add the listener to my_mcl wich is not your
movieClipLoader ... your MovieClipLoader was declared as site_mc.
You should have :
site_mc.addListener(mclListener);
site_mcl.loadClip("myswf.swf");

Similar Messages

  • "Detecting" a variable from an externally-loaded SWF via SWFLoader

    I load an external SWF file from a click event.  Then, when the interactions has reached the end of the presentation, we'd like it to unload itself, and go into another state.
    Is that possible?  ( actually transformed the SWF into a component using Flash Builder 4 hoping that would be easier to detect variables and events)
    Thanks,
    Doug

    It is possible, but you'll have to wire up the communications between the
    SWFs

  • Loading a remote SWF via SWFLoader Issue

    I have a simple flex app which loads an external XML into an
    arrayCollection using HTTPService send method. This works fine as
    both a stand-alone, or when loaded into it's parent as a LOCAL file
    via the SWFLoader tag. However, when I place this child file onto a
    remote server and try to load it into the parent which resides on
    my desktop, the ArrayCollection default resultFormat of the send
    method triggers the following runtime error (listed below). I don't
    think it's a sandbox issue because when I change result format to
    e4x, it works fine remotely. I've been hitting a wall on this for
    days now... Any insight would be greatly appreciated and thanks to
    all in advance!!!
    PARENT SWF (resides on local desktop)
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="vertical" initialize="initData()">
    <mx:Script>
    <![CDATA[
    public var baseURL:String;
    public function initSWF(swfURL:String):void {
    remote_swf.load(swfURL);
    public function initData():void
    baseURL = "
    http://blahblahblah";
    Security.allowDomain(baseURL);
    ]]>
    </mx:Script>
    <!-- WORKS when loading child swf LOCALLY -->
    <mx:Button label="Load LOCAL SWF APP"
    click="initSWF('remoteSWF.swf')"/>
    <!-- DOES NOT WORK when loading child swf REMOTELY -->
    <mx:Button label="Load REMOTE SWF APP" click="initSWF('
    http://blahblahblah/remoteSWF.swf')"/>
    <!-- LOADER -->
    <mx:SWFLoader height="100%" width="100%" id="remote_swf"
    autoLoad="false" visible="true" scaleContent="false"/>
    </mx:Application>
    CHILD SWF (resides on remote server)
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="getXMLData()">
    <mx:HTTPService id="myTeams" url="
    http://blahblahblah/xml/myXML.xml"/>
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.rpc.events.ResultEvent;
    import mx.collections.ArrayCollection;
    public function getXMLData():void
    Alert.show(Security.sandboxType);
    myTeams.send();
    ]]>
    </mx:Script>
    <mx:Label text="THIS IS THE LOADED SWF WHICH HAS JUST
    PERFORMED A SEND ON HTTP SERVICE TO CREATE ARRAY
    COLLECTION"></mx:Label>
    </mx:Application>
    ------------ RUNTIME ERROR ---------------------------------
    ArgumentError: Error #1063: Argument count mismatch on
    Object/
    http://adobe.com/AS3/2006/builtin::hasOwnProperty().
    Expected 0, got 2.
    at mx.rpc.xml::SimpleXMLDecoder/decodeXML()
    at mx.rpc.xml::SimpleXMLDecoder/decodeXML()
    at mx.rpc.xml::SimpleXMLDecoder/decodeXML()
    at mx.rpc.http::HTTPService/
    http://www.adobe.com/2006/flex/mx/internal:rocessResult()
    at mx.rpc::AbstractInvoker/
    http://www.adobe.com/2006/flex/mx/internal::resultHandler()
    at mx.rpc::Responder/result()
    at mx.rpc::AsyncRequest/acknowledge()
    at :irectHTTPMessageResponder/completeHandler()
    at
    flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio
    n()
    at flash.events::EventDispatcher/dispatchEvent()
    at
    flash.net::URLLoader/flash.net:URLLoader:nComplete()

    After further investigations, it appears that the problem might be, due the fact that in the remote (loaded) swf, the following is null:
    var sm:ISystemManager = ISystemManager(SystemManagerGlobals.topLevelSystemManagers[0]);
    sm.swfBridgeGroup <----- equals null
    I tried creating the swfBridgeGroup in the local (loading) swf, but the loaded one still thinks it is null.
    Any ideas?

  • Will app store approve an app to load external swf containing actionscript code in it?

    Will app store approve an app to load external swf containing actionscript code in it?

    Hi...It is not in the application bundle...it will be hosted on a server and from there it will be loaded in the application. I had created one sample application where it is loading a swf which is hosted on different server. This swf contained some actionscript code on its timeline. This app was working on ipad. I just wanted to know whether App Store will approve this.

  • Loading external SWF in Actionscript 2

    I am creating an animation within Flash CS4 in Actionscript 2.0 / Flash Player 7
    At the moment I have a handler (Movie Clip) called myHolder that is used to play other swf files within one main swf file, when called by a button
    Within a button that load the swf into the main timeline - For Example
    on (press) { loadMovie("BulletTrainDRAFT.swf", myHolder); }
    This works fine with bring other swf files into the main swf file timeline, but when I bring a swf file that has video controls for a video within it, they do not respond within the handler when played, but they do work when that swf file is played within its own external flash player window (The video is within a (Movie Clip) on its own timeline within its design fla)
    Video buttons - ActionScript 2.0
    btnStop.onPress = function(){  _root.vid.stop();  } btnPlay.onPress = function(){  _root.vid.play();  }  btn_fastforward.onPress = function(){  _root.vid.nextFrame();  }  btn_Rewind.onPress = function(){  _root.vid.prevFrame();  }
    I tried ActionScript 3.0 code as well
    Pausebtn.addEventListener(MouseEvent.CLICK,pauseHandler); Stopbtn.addEventListener(MouseEvent.CLICK, stopHandler); Playbtn.addEventListener(MouseEvent.CLICK,playHandler); 
    function stopHandler(event:MouseEvent):void { // Pause the stream and move the playhead back to // the beginning of the stream. video.gotoAndStop(1); } function playHandler(event:MouseEvent):void { // Pause the stream and move the playhead back to // the beginning of the stream. video.play(); } function pauseHandler(event:MouseEvent):void { // Pause the stream and move the playhead back to // the beginning of the stream. video.stop(); }
    Problem I have I think, is that a movie the external swf loads on the existing timeline as a child and doesn't unload the timeline resulting the actionscript not functional, but I can't fix this.

    if the loaded swf with video is an as2 swf, add:
    this._lockroot=true
    to it's main timeline.

  • Applying an onDrag actionscript to a loaded swf

    I want to make a loaded swf file dragable within the main
    stage. Can someone point me to a tutorial or show me how to do it?
    Thank you!

    This one took a few tries to get right. But I think I figured
    it out for yuh'. I assumed you were using a "ScrollPane" for your
    scrolling and that there was a button inside of that component. Let
    me know if this is wrong. It shouldn't be too different even if
    you're not using the "ScrollPane". Aslo, all the code below goes on
    the main timeline.
    notes:
    "container" is the empty clip that holds the content.
    "mc" is the MovieClip inside of the ScrollPane ( located in
    the loaded *.swf ).
    "mouseIsDown" is a boolean ( true/false). It checks to see if
    the user is holding down on the mouse or not.
    The rest is pretty easy to figure out.

  • Loaded SWF not displaying

    I've created a 'plugin' SWF file in CS3 using actionscript 3.
    The purpose of this file is to be included as a postroll in the
    open source flash media player JW FLV/Media Player (
    http://www.jeroenwijering.com/?item=JW_Media_Player).
    I have heavily customized the media player libraries to do
    various new things/alter how things worked, and now want to be able
    to include the SWF file within this into a child sprite/movie clip.
    HOWEVER, the problem lies in that the media player is written
    completely in AS2, and therefore I have to use the MovieClipLoader
    class to load in the SWF. Updating the source to AS3 isn't an
    option unfortunatly, and downgrading the AS3 SWF to AS2 isn't an
    option either, mainly due to the fact I've learnt AS3, not AS2, and
    find it frustrating trying to find the AS2 equivalent to the AS3
    methods I know.
    The problem though lies in that MovieClipLoader does not like
    my SWF at all. Initially I was presented with a load of sandbox
    errors from when it was loaded in, which I then resolved so that no
    security errors are produced. However, whenever I load in the clip,
    the target sprite/clip is empty. I have gone through checking that
    no errors occur on load, and it reports that the loaded SWF has
    been initialized, yet I see nothing. Also, the code loading the SWF
    is not at fault as it loads any other SWF (even another AS3 SWF
    which just creates a rectangle) no problem.
    Oddly enough, using the MovieClip.loadMovie method works in
    one situation - when you load it into the root of the AS2 file.
    When loading it into an empty movie clip, the same problem of a
    blank clip occurs. The problem is not specific to the media player
    either, as it happened in any AS2 file where I was testing how to
    load in the AS3 SWF.
    If it is of any use, the sandbox errors produced by the AS3
    file when loaded into AS2 swf I had to resolve where to do with
    stage access for getting the stage height and width, and a
    Loader.content error when pulling out the BitmapData. These were
    resolved via setting the allowed domains policy and eliminating any
    reference to stage.stageHeight/With.
    Does anyone have any ideas on how to solve this? The only
    possible solution I've been able to think of so far since the AS3
    swf won't display is to play with the LocalConnection class as
    tests showed I can communicate between the AS2 and AS3 files, but
    this would have to be a last resort, and is less than ideal when
    there can be multiple instances of the player running (I would need
    to use unique connection names for each instance so as to prevent
    player A interacting with player B, and also as only one of the
    players can listen on the connection at once).

    I have the component in the top level also,
    I get this error:
    TypeError: Error #2007: Parameter child must be non-null.
              at flash.display::DisplayObjectContainer/addChildAt()
              at fl.controls::BaseButton/drawBackground()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\BaseButton.as:615]
              at fl.controls::LabelButton/draw()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\LabelButton.as:724]
              at fl.core::UIComponent/drawNow()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\core\UIComponent.as:1343]
              at fl.controls::List/drawList()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\List.as:594]
              at fl.controls::List/draw()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\controls\List.as:474]
              at .tree::TreeList/draw()
              at fl.core::UIComponent/callLaterDispatcher()[C:\Program Files (x86)\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\User Interface\fl\core\UIComponent.as:1532]
    I've checked the definitions for the tree component,
    The LabelButton and List I don't have much control over.
    I'm not sure how to fix this.  The xml is correct and loads easily if it's in the root document.
    The list component doesn't load the labels, It stops on the first one.
      What do I do next?

  • Calling functions / setting variables in loaded SWF

    You know how you can create a Movieclip object, add a
    function or variable to it, then call that function or change that
    variable from within the SWF that includes it? I wanna be able to
    do that, only with SWFs that are loaded at run time.
    My "main" SWF is simply a menu-type thing. The user clicks a
    button in my MAIN.SWF, and the MAIN.SWF then loads the SWF that's
    associated with that button, using the AS 3.0 prescribed
    Loader()-URLRequest()-addChild() method that everyone always asks
    about.
    This works great. But now I've got some custom objects and
    such (ie., not just strings) within my MAIN.SWF that I'd like to be
    able to share with the loaded SWFs. Preferably, I'd like to use an
    accessor-type function (ie.,
    LoadedSWF.GiveMeTheCoolObject(MyCoolObject);), though at this point
    I'm willing to hack into the object itself (ie.,
    LoadedSWF.CoolObject.CoolField = MyCoolObject.CoolField;) if that's
    what it takes.
    I've tried just calling the functions and setting the fields,
    but the AS 3.0 compiler doesn't care for that sort of nonsense on
    it's generically-defined objects. Notice also that, at run time, a
    call to LoadedSWF.hasOwnObject("GiveMeTheCoolObject") returns true.
    So my big-brained colleagues, what's the magic?
    In advance, thanks for the help!
    Scott

    Kglad,
    quote:
    Originally posted by:
    kglad
    from that error message it appears your function is expecting
    a member of the MyCoolObject class, correct?
    and MyCoolObject is not an instance of that class. so, you
    need to fix that. ie, create a member of that class and use that
    class member as the function parameter.
    Heh, that's what the error message says all right. But the
    object actually IS a MyCoolObject class object. I stared at this
    thing for hours, and MyCoolObject IS an instance of that class. I
    tried various casting combinations (including casting it to an
    Object and passing that) but had no luck whatsoever.
    So I googled this particular runtime error message ("Error
    #1034: Type Coercion failed: cannot convert ") and found a ton of
    links to other people having a similar issue. Typically, the
    problem was just as you said, someone passing a button as a string,
    that kinda thing. But one guy had a problem with an object he
    derived from the Event class. After hours spent trying to get it to
    work, he tried overriding the base class' clone() method and got it
    to work:
    http://www.asserttrue.com/articles/2006/10/14/custom-events-in-actionscript-3-0
    As for my project, I took a long hard look at the overall
    architecture of my project and decided that it was best if all the
    "real work" took place in the MAIN.SWF file. This approach would
    solve a couple of other problems, and it just makes sense in a
    "separate the display from the data" mentality.
    So (and this is the interesting part) I changed the API for
    the LOADED.SWF to accept String pairs (ie.,
    LoadedSWF.AddToDisplay(Name:String, Data:String) ) instead of
    accepting MyCoolObj. Ran it, and Viola, now we're working without
    any run time exceptions. After that glorious moment, I created a
    couple of other APIs that just accepted base classes (one an int
    type, the other a function type) and was happily on my way.
    From this, I gather that passing non-base class (ie, derived
    class) objects to loaded MovieClips via custom function APIs is...
    maybe not as straightforward as we'd expect. In the grand scheme of
    things though, not a big deal: As far as I'm concerned AS3 rocks.
    Again Kglad, thanks for all the help: Your input on how to do
    this was the big push that I needed to get over the last technical
    hurdle of this project.
    To those who are reading this topic for the "how do I call
    functions and/or set variables in a loaded SWF?"
    The short answer is to cast the loaded SWF's content object
    as a MovieClip and then call the function or alter the variable:
    //Load the SWF (you've seen this code a million times)
    var LoadedSWFObj:Loader = new Loader();
    var MyURL:URLRequest = new URLRequest("LoadThisSWF.SWF");
    LoadedSWFObj.load(MyURL);
    //This is within your Event.COMPLETE handler:
    //Cast it as a MovieClip object and work with that.
    var LoadedSWF:MovieClip = LoadedSWFObj.content as MovieClip;
    // or another way to cast it is:
    var LoadedSWF:MovieClip = MovieClip(LoadedSWFObj.content);
    //Call yer function:
    LoadedSWF.CallMe();

  • Using Loader.loadBytes - specify SecurityDomain for loaded swf?

    Hi i have a problem.
    I use Loader.loadBytes to dynamically load a swf into my app (i use this method to load modules into the app). My trouble is that when I want to use ExternalInterface.addCallback to allow js calls on my app. When those functions get called a SecurityError gets thrown because I'm not in the right Security Domain. Trying to set the SecurityDomain of the loaded content via LoaderContext results in another error telling me that SecurityDomain can't be other than null. Is there a way to actually get my modules accessible from JS?
    *Note:
    I have set in my main ap (the one that instantiates the module controller that loads the modules) the following:
    Security.allowDomain("*");
    Security.allowInsecureDomain("*");
    the loading code:
    var _contextLoader : LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
    _contextLoader.allowCodeImport = true;
    _moduleLoader.loadBytes(moduleBytes, _contextLoader);
    The error:
    SecurityDomain 'null' tried to access incompatible context ...

    The loaded swf is at loader.content, but you can only access
    it once the loading has completed and the loader has been added to
    the display list. For example, CODE 1 will not work, but CODE 2
    will.
    //CODE 1
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    myLoader.load(new URLRequest("movie.swf"));
    var loadedSwf:MovieClip = MovieClip(loader.content); //ERROR
    //CODE 2
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    myLoader.load(new URLRequest("movie.swf"));
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    loadCompleted);
    var loadedSwf:MovieClip;
    function loadCompleted(ev:Event):void {
    loadedSwf = MovieClip(loader.content);
    trace(loadedSwf);
    PS. I recommend using the Tweener library for tweening in
    ActionScript. It is much better than the Adobe functions and there
    is a tutorial at:
    http://gotoandlearn.com/player.php?id=45

  • Load swf file in as 2

    hi i want to in site.swf flash file load picture.swf flash
    and show it in middle of site.swf is it possible?and can somewone
    help me to how do this or give an example link

    That's pretty straight forward, just use the code snippet
    below
    _root.createEmptyMovieClip("newMC", getNextHighestDepth());
    newMC.loadMovie("yourswf.swf", this);
    newMC._x = Stage.width / 2;
    newMC._y = Stage.height / 2;
    With the code above your newMC which has been created via
    actionscript is loading any swf files into it, and positions the
    movieclip exactly in the middle of the stage.

  • Is it possible to load SWF files from an SQL database?

    Hi all, I am very new to flash (I am primarily a C'# developer!) and I have been asked to investigate the possibility of doing the following;
    Create an application that allows swf files to be uploaded and stored inside of a SQL database as binary data (Why a database is a long story!)
    Allow this binary data to be extracted via a http request to be dynamically loaded inside of a web page.
    Now the first part was easy. I have all of my swf's uploaded and stored inside of the database. I have code that can make a request for the binary and write it to the response, so far so good. Now this is where I am stuck.
    I thought I could dynamically load the swf binary data by creating a very basic swf that simply contains a movie clip holder and for now a simple loadMovie statement. My idea being that I can could provide a url for the loadMovie statement that returns the swf binary data. This is where I have ground to a halt.
    I can see the call being made from the swf, I can see the data being returned but I cannot get it to render. I remember seeing an article some time agao where someone stated that they had used this method with success but I cannot find now. Has anyone ever done anything like? Is it even possible? Am I missing something simple?
    I have tried to return both the raw binary data and also used response.write but to no avail. Can anyone help?

    You are possibly trying to load AS3 swf into an AS2 Container at least the use of loadMovie() points in that direction. Be sure to use AS3 and target at least Flash 9 in your Loader/Main.swf. Also the AS3 concept of how to load swfs  differs a lot from the old concept.
    Look into the docu:
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.ht ml
    But the biggest Problem seems to me -what you mentioned- that Loader needs a (defined) URLRepuest and since your swf files have no "real" URL and you surely don`t want to let the user directly write to your server, a workaround would be to write the BinaryStream with AIR-functionality to a local installlation directory and load it then from there.

  • Load SWF file in main SWF with parameters

    Hello everybody,
    I recently got a new flash Application which is a Photo Gallery.
    This App is made of multiple folders (source files), a FLA file, a SWF with its javascript SWFObject and an Html page which instantiate this App with some parameters (size, config file path, ...).
    It needs an XML file to find all the Photos it displays, to do it I need to configure my application in the HTML Page and give it the "xml_path" :
    var so = new SWFObject("index.swf", "gallery", "249", "249", "10", "#111111");
    so.addVariable("xml_path","load/config.xml"); // this line is adding the path to the xml file make sure that it's name is xml_path
    so.addParam("allowfullscreen","true"); 
    so.write("flashcontent");
    By the way, I have a second application, the WebSite, which have to display the Gallery SWF in its "Gallery" page.
    Here is how I do it at the moment (in ActionScript3) :
    var swfRequest:URLRequest = new URLRequest("C:/......../Galerie/index.swf");
    var swfLoader:Loader = new Loader();
    //Charge le SWF Galerie dans le SWF Site
    swfLoader.load(swfRequest, context);
    container1.addChild(swfLoader);
    //Positionne le SWF
    swfLoader.x=10;
    swfLoader.y=120;
    It successfully loads the Gallery application but It shows an error telling me it doesn't find the XML configuration file... In the HTML file I simply had to write the "so.addVariable("xml_path","load/config.xml");" to tell where the XML file is...
    So, my question is : How can I integrate my SWF application giving it some parameters like above, in Action Script 3?
    Thank you ,
    Patrick

    No, nothing with HTML.
    I have 2 SWF applications. One is the Gallery, and the second is my Main Page.
    My Main Page must integrate the Gallery module in one of its page.
    The problem is when I try to integrate it, I think I must give de future loaded SWF some parameters like this :
    (My Main SWF loading in HTML)
    var so = new SWFObject("WebSite.swf", "flashcontent", "520", "700", "10", "#111111");
    so.addParam("allowfullscreen","true");
    so.addParam("allowScriptAccess","always");
    so.addParam("menu","false");
    so.addParam("wmode","opaque");
    so.addParam("bgcolor","#000000");
    so.setAttribute("id","flash");
    so.write("flashcontent");
    It was for the Main App. For my Gallery SWF I had to load it like this (in HTML) :
    var so = new SWFObject("Gallerie.swf", "gallery", "249", "249", "10", "#111111");
    so.addVariable("xml_path","Galerie/config.xml"); // this line is adding the path to the xml file make sure that it's name is xml_path
    so.addParam("allowfullscreen","true"); 
    so.write("flashcontent");
    So at the beginning I had 2 different projects with an HTML page for each.
    Now I wan't to directly integrate the Gallery SWF into the Main SWF. And as you have seen I must give it some parameters such as the "xml_path" and "allowfullscreen". This must be done in ActionScript 3 and I don't know how...
    I think I have to use FlashVars but I don't know how. As I said before, I have tried using the loaderinfo.parameters, but it is in read-only...
    Do you have an idea of how I can make it work ?

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

  • Can a loaded SWF call a function that lives in the parent?

    I'm building a pretty simple Flash site in AS3. There is a
    main movie (main.swf) that simply loads different swfs via buttons
    on a main nav bar. The user clicks on a MC in "main.swf" and a
    function is called, loadMyContent("section1.swf"), is called and it
    animates in nicely. Other buttons use the same function, loading
    section2.swf, section3.swf, etc.
    I've defined how "loadMyContent()" works in the the main
    movie's document class file. It's all working fine when I just need
    to load content from a user action from the buttons that live in
    "main.swf". I want to call that same "loadContent" function from
    within "section1.swf" and have "main.swf" run it's "loadContent"
    fuction, but I can't seem to figure out how to make a child call a
    function that lives in the parent.
    Is there any way of having my child do this?
    I have a suspicion I may have to define that "loadContent"
    somewhere else, but I'm a little stumped now. I'm not really
    familiar with design patterns yet, although I want to get an
    understanding of them sometime soon. Can anyone offer some help
    with my immediate need or suggest a route to a solution?
    Thanks.

    kglad,
    Thank you very much! That worked perfectly. My section1 FLA
    is now compiling it's SWF without complaint.
    In case someone else is following this, the exact code I
    ended up using to cast "this.parent.parent" as a MovieClip is:
    MovieClip(this.parent.parent).loadMyContent("section2.swf");
    The discussion I think kglad is referencing is
    this
    discussion. If that's not it, just let me know. Again, kglad,
    thank you!

  • How to access properties of symbols in loaded SWF?

    I'm making the migration from Flash to Flex, but I'm running
    into a dead end on one particular area: accessing and manipulating
    properties of symbols in a loaded SWF.
    The SWF is actually a simple library of a detailed parts
    illustration. I would like to load the entire SWF in position, and
    be able to change the attributes (i.e. colors) of individual
    symbols (or parts of the illustration). I can load, display and
    manipulate each symbol separately, but I need the parts to remain
    in place.
    The original art was created in Illustrator and exported as
    SWF using the symbols palette.
    I can always go back to Flash, but I'm forcing myself to move
    forward and do this project in Flex (baptism by fire!!).
    Is there some sort of dot notation to access the symbols from
    within the SWF, without loading them all separately?
    Let me put this another way: it appears that I can load an
    SWF and then instantiate each symbol in that SWF, and then load
    each symbol to the 'stage' (or whatever it's called in Flex)
    separately.
    I can certainly instantiate each symbol separately, and then
    align it on stage, but it seems to me to be bass-ackward to do it
    that way, expecially since I created the original SWF with
    everything in position.
    Is there no way to access the attributes of the individual
    symbols within an SWF without separately instantiating them?
    I'm just having trouble getting my head around this. Any help
    is greatly appreciated.

    Okay, I took a look at this info and it's what I was already
    doing.
    Here's a simplified example of what I'm trying to do, using
    the example in the swf9.pdf file.
    Let's assume I've created a SWF with a "BlueSquare" movieclip
    (in the symbols panel in Flash, exported for AS). In that clip,
    there is another symbol called "Star". I import the SWF and
    BlueSquare symbols in with the following code:
    <mx:Script>
    <![CDATA[
    [Embed(source=”../assets/circlesquare.swf”)]
    [Bindable]
    public var LogoCls:Class;
    [Embed(source=”../assets/circlesquare.swf”,
    symbol=”BlueSquare”)]
    [Bindable]
    public var LogoClsBlueSquare:Class;
    </mx:Script>
    If I instantiate the BlueSquare on stage, it includes the
    Star symbol when previewed, but I can't figure out how to get at
    the Star symbol to change color. If I apply a color change to the
    symbol, it changes the entire BlueSquare symbol.
    If I instantiate the Star symbol separately, I can then
    position it on the stage and make changes, but that requires
    positioning it with actionscript. I'm trying to not have to
    position a sub-element of my actual artwork because of it's
    complexity.
    I'd like to display the main movieclip (or sprite) with the
    ability to access the attributes of a sub-movieclip or
    sprite.

Maybe you are looking for