Listen for a variable in externally-loaded interactive swf

Hi,
I'd like to set a variable inside an externally-loaded swf created in Flash Professional that is playing inside a Flex 4 application.  The swf will "signal" the end of an interaction (using a s:SWFLoader).  Once the variable is set (by arriving at a particular frame inside the externally-loaded swf, I'd like my Flex 4 application to "know" and take action to unload the swf and then "navigate" to another state with a new Flex-based interraction.
Perhaps a step-based illustration will be more clear:
1.  Clicking a textfield inside a Flex 4 application loads a custom component that uses an <s:SWFLoader> to load an external SWF that includes buttons to navigate through frames in a "slideshow" fashion.
2.  Once the end of the "slideshow" is reached, a variable is instantiated by
               var swfEND:String = "swfDne";
3.  I'd like my Flex 4 calling application to know when this event occurs, then I'd like the sef to unload and Flex to goto another state.
Any help, particularly on how to detect events in external swfs from Flex will be greatly appreciated.
Thanks,
Doug

wanaryd,
> In my main timeline on frames this variable is changed
> (color = "red";) When the main timeline changes to a
> different location a new color is set. How do I make the
> movie clip listen for the color variable to change?
When the timeline changes to a different location, something
in that new
location changes the value of your color variable -- so why
not just update
the code in that location (or those locations) and have them
perform the
functionality that depends on the variable's value?
In any case, you should be able to use the Object.watch()
method.
Instead of creating a simple variable, create an instance of
the Object
class, then use the Object.watch() method to keep an eye on
things.
http://my.opera.com/darylducharme/blog/2007/02/13/the-object-watch-method
David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."

Similar Messages

  • Rotate entire .swf OR load interactive .swf into .fla?

    Hello, I've searched extensively for solutions to my problem and decided to come here finally.
    I need to rotate an entire .swf flash game from horizontal display to vertical display. Not a change in aspect ratio, but a 90-degree rotation.
    Having found absolutely NO programs to directly do this online, I'm now trying to import the game into flash to rotate and then export as another .swf.
    The loadMovie() command only works well for non-interactive .swf movie files, and simply plays all the frames of the flash game in succession.
    Help, please?

    I'm guessing your start button might use a _root reference, which will not work unless you use _lockroot in the loaded file.  Try placing the following command on the main timeline of the loaded swf...
    this._lockroot = true;

  • Accessing parent variables in externally loaded swf - Help please

    I thought I knew how to do this, but maybe someone might be able to see why this is not working...
    here's what I have (simplified to only show necessary code):
    Main Timeline:
    var currentItem:String = 'applesauce';
    (then some code to load an external swf)
    External swf main timeline:
    trace(currentItem);
    it returns "undefiend"
    i have tried
    trace(MovieClip(root).currentItem);
    trace(MovieClip(this.parent).currentItem);
    each time undefined, any ideas?

    movieClip(parent.parent)
    supposedly ... didn't work for me ... but it was explained the 1st parent reference is the loader .. the second the maintimeline ..
    if your loading it into a MC .. add an additional parent ref ..

  • Externally loading a SWF

    Okay, I am making my portfolio and I am having problems
    loading the galleries into the main index/main page.
    I am using the "loader" component, and telling it to load the
    EXACT file name of the SWF.
    This is the error I get:
    Error opening URL
    'file:///Macintosh%20HD/Users/ARP/Library/Caches/TemporaryItems/index_graphic.swf'
    I have an index_graphic.fla & index_graphic.swf
    WHY IS THIS NOT LOADING?!
    I am a newbie at flash, so I need it to be straight forward.
    THANKS A MILLION. I really need to finish this
    tonight!!!!!!!!

    Save your Flash movie to a specific location, maybe a folder
    on your desktop. Then put the .swf into that folder.
    If you have not saved the file that you are currently working
    on, then Flash has no idea what the relative path for that file.
    What you are seeing in the error is the Mac default working file
    path.

  • AS3 pass variables-values from loaded external swf to parent swf

    Hi,
    I am working on an eLearning project that uses a main SWF (SWF1) and a second SWF (SWF2) with 2 quizzes in it. Published to AIR for Desktop and Android, SWF1 and SWF2 are packaged together in the AIR desktop or AIR APK exports.
    I can use a loader in SWF1 to call and run SWF2. What I am having difficulty with, need some help, is how to get the 2 scores from the 2 quizzes in SWF2 and load these values (each is a Number) back into SWF1. Once back in SWF1, they will be written to String and then displayed in a text box using textbox.text.
    While I've searched online and found examples for sending variables from parent to child SWF's, so far not able to find an understandable/useable AS3 script example for getting variables from child to parent SWF.
    Any help appreciated.
    Best Wishes,

    Hi,
    Still stuck. Can't get SWF2 to go back to SWF1 frame 2.
    SWF1, based on Kiran's AS file with the class AppEvent (class is not called in SWF1 until frame 2, and is called in SWF2 frame 9) loads SWF2 using:
    //SWF1, frame 2
    stop();
    import flash.display.Loader;
    expB100.addEventListener(MouseEvent.CLICK, L1, false, 0, true);
    function L1(e:MouseEvent):void {
    loaderL1.load(new URLRequest("Hotspot13.swf"));
    loaderL1.contentLoaderInfo.addEventListener(Event.COMPLETE, onChildLoaded);
    addChild(loaderL1);
    expB100.visible = false;
    function onChildLoaded(evt:Event)
        var child:DisplayObject = evt.target.content as DisplayObject;
        child.addEventListener(AppEvent.CHILD_DATA, getChildData);
        addChild(child);
    function getChildData(evt:AppEvent):void
        trace(evt.data.var1,evt.data.var2);
        tTest.text = String(evt.data.var1);
        tTest2.text = String(evt.data.var2);
    I wonder if there is some confusion between MovieClip and DisplayObject when SWF2 tries to return to SWF1 frame 2, using MovieClip(parent.parent).gotoAndStop(2); and gets an error?:
    Error #1034: Type Coercion failed: cannot convert flash.display::Stage@2f1ef71 to flash.display.MovieClip.
        at Hotspot13_fla::MainTimeline/onClick()[Hotspot13_fla.MainTimeline::frame9:124]
    Hotspot13 is SWF2; SWF2 frame 9 uses the following to try to return to SWF1 frame 2, causing the above error:
    function onClick(event:MouseEvent):void
        trace(this,this.parent,this.parent.parent);
        dispatchEvent(new AppEvent(AppEvent.CHILD_DATA,{var1:score1,var2:rbselectedT},true)); 
        MovieClip(parent.parent).gotoAndStop(2);   
    Or maybe the AppEvent.as file is imported in frame 1 when it should be imported in another later frame like SWF1 frame 2 where it is first used?
    Best Wishes,

  • Set a value for a variable of type exit

    Hello,
    I am filling some variables with multiple values in user exit.
    Now, i would like to place some of these characteritics in Header area. It's of course impossible because there is multiple values but ...
    I will put dropdown box in the web application for these chars. The problem is that by default, any value is assigned to the dropdwom ( any variable value is set).
    Do you know how i can set a value for theses variable after filling all values by the user exit. SO that only one value is selected for the header and all others values available in the dropdown ?
    Regards,
    Jarod

    Hi,
    Off late, this seems to be a usual requirement.
    Just create a Z program to call the FM API_SEMBPS_VARIABLE_SET and then call the FM API_SEMBPS_POST.
    you should be preparing the content/set value to pass to the FMs. check the whereused list to see how this FMs can be used/called.
    finally, run this program for your variable, after the loading/filling the exit variable. Please note that to set 'exit' variables, the sourcing variable's content need to be read/set first before setting the exit varible.
    HTH,
    Regards,
    Nataraj.

  • Loading two swfs and playing them sequentially

    Hello Team,
               I have searched, but can't seem to find an answer to my question.  I'm working in Flash cs6 on Windows platform. I do not understand how to load two external swf files into another swf file(Main swf) and have them play sequentially. I certain that this task is extremely small to a lot of members of this forum, but if someone could be so kind to assist me with this inquiry I will be over-joyed.
    I am able to load one swf with the following code:
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swf/gallery.swf");
    loader.load(defaultSWF);
    addChild(loader);

    AS3 - Dispatch Event
    Example:
    Add something to trigger the event in the child:
    dispatchEvent(new Event("eventTriggered"));
    (if dispatchEvent problem, see: http://www.kirupa.com/forum/showthread.php?p=1899603#post1899603)
    The listener for this event has to be added to the main file AFTER the external file has been loaded.  In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo. 
    yourLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler);
    In the complete event handler, add a listener for the event on the loaded swf.
    // event handler triggered when external swf is loaded
    function loaderCompleteHandler(event:Event) {
        MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
    Then just create the event handler for the dispatched event listener that was created in the loaderCompleteHandler function.
    function eventHandler(event:Event):void {
        trace("event dispatched in loaded swf");
        // load/play your second swf now

  • Crash to desktop when loading embedded swf

    I have a swf that loads two other embedded swfs. The need for an air native extension came up so I've wrapped this swf inside of an AIR app. I install my app as a native installer. (on Windows 7)
    My app has a main menu screen and two buttons that will load two separate swfs to do their own menus and actions.
    Everything has worked great, until I tried to install the AIR app on a computer without internet. I ran the air redistributable, then installed my app. The main menu runs fine, and the main swf can load one of the embedded swfs, but when it tries to load the second embedded swf it crashes to desktop. No warnings, no errors, I just see desktop after clicking a button.
    Here is how I'm loading the offending swf:
    Inside MM_DocumentClass.as
    [Embed(source="../../ContentViewer/bin/ContentViewer.swf")]
            public var CViewSwfClass:Class;
            public var CViewMC:MovieClip;
    Inside MMState_MainMenu.as
         //Load the CView.swf, and add the listener for when it's done loading.
            public function CView_BtnClick(e:Event)
                Globals.stage.removeEventListener(KeyboardEvent.KEY_DOWN, Globals.keyPressHandler);
                menuMC.removeEventListener("Animation_Complete", CView_BtnClick);
                trace(this + "******************************************************");
                trace(this + "Loading ContentView.swf");
                mStateManager.Container.CViewMC = new mStateManager.Container.CViewSwfClass();
                mStateManager.Container.CViewMC.addEventListener(Event.COMPLETE, onCviewLoad);
                mStateManager.ChangeState(new MMState_Empty());
            //Called when CView.swf is done loading
            private function onCviewLoad(e:Event)
                trace(this + "Cview Loaded");
                mStateManager.Container.addChild(mStateManager.Container.CViewMC);
    I load the other swf in the exact same way.
    This problem can be fixed by connecting the computer to internet and trying to run the same actions. The program will pause for a second, during this time I see a visible loading icon in the middle of the screen, then it successfully loads the swf and everything works fine.
    My problem is that I can't guarantee our clients will have internet at all, so I need a solution to install AIR without internet and include whatever it is that my app needs to run.
    Any ideas? 'Cause this one's had me stumped for quite awhile.

    Does this happen whith every subVI or just on particular one? Also, what version of LV and OS?
    Lynn

  • Watching for a variable in an external swf

    Hi,
    I'm trying to load an swf game, and then repeatedly run a check to see if the game has ended by accessing one of it's variables.  Reading the forums and searching the web has gotten me this far:
    var myLoader:MovieClipLoader = new MovieClipLoader();
    myLoader.addListener(this);
    myLoader.loadClip("game.swf", 2);
    function onLoadInit(mc:MovieClip)
         trace('testing");
    _root.onEnterFrame = function() {
        trace(_level2.LOCAL);
    "testing" appears on the output window so I know it's being loaded correctly, the game is also playing correctly.  When I run the game in debug mode, it shows that the variable _level2.LOCAL exists and has a value, but the main loop just keeps kicking out "undefined."
    I appreciate any help.

    Ok I figured out that to access it I have to use: _level2._root.LOCAL.
    Now my question is if there is a better way to watch a variable than running a loop.
    Also I was wondering if it's possible to listen for a function call in the external swf.

  • Accesing externally loaded variables

    i would greatly appreciate a pointer or two as i am having a
    painful transition to AS2.0
    an 8k zip test is at: www.cyan-animatica.com/v2/exttest.zip
    //(wasn`t there an option back in macromedia days to attach a
    file?)
    i am having a poblem accesing externally loaded variables :
    A.--------------------------------------------------------------------
    the external .txt has folowing content:
    &a1_0=hello&a1_1=bye&a1_2=whatever
    B.--------------------------------------------------------------------
    loaded on the first frame thus:
    var thumbs:LoadVars = new LoadVars();
    thumbs.onLoad = function(success:Boolean):Void {
    if (success) {
    trace("LoadVars loaded successfully: "+this.loaded);
    } else {
    trace("Error");
    thumbs.load("my_externals.txt");
    C.--------------------------------------------------------------------
    if want to access one of 3 loaded variable hardcoding, this
    works just fine:
    trace(_root.thumbs.a1_1) //bye
    BUT i need to do this based on the mc/buton name that calls
    it:
    on (press) {
    var kk:String = _name;
    trace(_root.thumbs.kk);
    i get UNDEFINED...obviously i am mixing datatypes if not
    worse
    pc win 2000
    flash prof for flash8 player[

    thanks for a prompt reply, blemmo.
    you write:<<to ADD vars to the LoadVars object, it has
    to be referenced correctly
    what i want to do is READ vars from LoadVars object and
    referencing is exactly what is killing me
    sorry bout the lack of clarity. the zip would help
    (www.cyan-animatica.com/v2/exttest.zip)
    i am loading 3 variables into an object var thumbs:LoadVars
    from one external .txt file:
    a1_0=hello
    a1_1=bye
    a1_2=whatever
    i want to see the contens of let us say the second variable
    trace(_root.thumbs.a1_1);
    produces bye , perfectly - this is exactly what i want, but i
    want it based on a constructed reference
    so, i have button in an mc named "a1_1", the button script
    is:
    on (press) {
    var kk:String = _name;
    trace(kk); // produces a1_1
    trace(_root.thumbs.kk); //this should be same as
    _root.thumbs.a1_1 and produce the same result, but does not
    i suspect that the problem is that kk is declared as string
    datatype, but no matter what i do i cannot get a result
    thanks for your help

  • I cannot seem to load raw images into LR 2.5.  I've been using this for years.  I always load from memory card, but it gives me an unknown error message.  I tried to load from camera, hard drive, & external drive and still will not work.  I checked import

    I cannot seem to load raw images into LR 2.5.  I've been using this for years.  I always load from memory card, but it gives me an unknown error message.  I tried to load from camera, hard drive, & external drive and still will not work.  I checked import menu and nothing has changed.  I loaded the photos onto my tablet and images are fine, so do not feel it is the memory card.  Any thoughts?

    The error message probably said "unsupported or damaged"
    The T3 requires Lightroom 3.4.1 or later. You can either upgrade to a more current version of Lightroom (version 5.6 is the most recent) or you can use the free Adobe DNG Converter to convert the RAWs to DNG, which should import into Lightroom properly.

  • Drag and Drop for Externally Loaded Videos

    Good day to all. Thanks for viewing. My problem is that im trying to click and drag videos externally loaded onto the flash stage. Apparently normal drag-drop methods won't make it work Anyway to work around this error? Thanks! Here's what i've came up with so far.
    var videoConnection:NetConnection = new NetConnection();
    videoConnection.connect(null);
    var videoStream:NetStream = new NetStream(videoConnection);
    videoStream.play("video.flv");
    var video:Video = new Video();
    video.attachNetStream(videoStream);
    addChild(video);
    video.addEventListener(MouseEvent.MOUSE_DOWN, dragMovie);
    video.addEventListener(MouseEvent.MOUSE_UP, dropMovie);
    function dragMovie(event:MouseEvent):void
      video.startDrag();
    function dropMovie(event:MouseEvent):void
      video.stopDrag();

    var mySprite:Sprite = new Sprite();
    mySprite.addChild(video);
    addChild(mySprite);
    Then add listeners that you added to video -  to mySprite.

  • Listening for UncaughtErrorEvents from SubApp loaded by SWFLoader

    I can't seem to get my uncaughtErrorEvents listener to fire when attached to the loader.uncaughtErrorEvents  or loaded content's loaderInfo.uncaughtErrorEvents when loading a swf via SWFLoader.
    I have a main Flex Application ('A.swf') loading a SubApplication  (defined in' B.swf') via a SWFLoader and I need to listen for  UncaughtErrorEvent from the SubApplication. I'm not able to get my event  listeners to be called when I throw an error from within the SubApp  ('B.swf').
    After reading the asDoc for UncaughtErrorEvent and  UncaughtErrorEvents It states that the UncaughtErrorEvent should go through the normal capture, target, and bubble phases through the loaderInfo hierarchy. This doesn't seem to be the case or I'm not understanding the documentation/usage.
    I have added an event listener to A.swf's loaderInfo  (The 'outter' main app) and also to B.swf's loaderInfo (though the Docs  say not to do it here it is part of the event sequence in the capture  and bubble phase...) as well as the SWFLoader internal  FlexLoader.uncaughtErrorEvent (per Docs) like so:
    SWFLoader's internal FlexLoader uncaughtErrorEvents
    swfLoader.content.loaderInfo.loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorFunction );
    and the loaded SWF's loaderInfo:
    swfLoader.content.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorFunction );
    When I throw an Error from the SubApplication (B.swf). Only the 'outter' main app's (A.swf) event listener gets called. Which you expect, at first, if it is in the capture phase, but it isn't in that eventPhase at all. When debugging the eventPhase is in the EventPhase.AT_TARGET phase while being handled by A.swf's LoaderInfo, howeever the ASDoc says the Target phase should be B.swf's LoaderInfo.
    Is this a bug between Flash player and Flex where the event isn't flowing correctly as stated in the ASDoc for UncaughtErrorEvent?

    Thanks for the reply Alex.
    The Outer main swf and the SubApp swf are in different ApplicationDomains (sibilings to each other) so they should not be sharing the class that is throwing the error. I should note that these two Applications are purely based on MX components, this is important later on.
    I was originally throwing the error from a Button click handler from B.swf:
    <mx:Button label="Throw Error" click="callLater( throwUncaughtError )" />
    I was wrapping the handler function in a callLater because without it the error is not caught at all and the default flash dialog console just appears with the error. The A.swf's loaderInfo.uncaughtErrorEvents handler was not even firing unless I wrapped it a callLater.
    I realized that Flash Builder's default to link the 4.1 SDK library via Runtime shared libraries was what was causing the A.swf's loaderInfo.uncaughtErrorEvent to fire in the AT_TARGET phase when using callLater. This is because the UIComponent's callLater method queue structure is shared between the two SWFs and therefore inside a function executing off the method queue A.swf's loaderInfo IS the TARGET... explainable, but at first thought that isn't how I'd expect this to work.
    I then decided to test this out by setting the SDK library to merge into the code for both A.swf and B.swf and removing the  callLater. IT WORKS!  B.swf's (the SubApp) loaderInfo.uncaughtErrorEvents handler fires and I prevent the default (flash error console from appearing) and can stopImmediatePropagation so A.swf's loaderInfo.uncaughtErrorEvents handler doesn't fire.
    Perfect besides having to merge the SDK libraries into each swf independently.... size killer.
    In summary, using the same exact code for A.swf and B.swf:
    1. When the SDK libraries are RSL - no UncaughtErrorEvents, neither A.swf's or B.swf's, is called. Instead the default flash error console appears with no chance to handle the uncaught error.
    2. When the SDK libraries are Merged into the code - both A.swf's and B.swf's uncaughtErrorEvents  will be called, according to the asDoc documented sequence; B.swf's uncaughtErrorEvents in the AT_TARGET phase and A.swf's uncaughtErrorEvents in the BUBBLE phase.
    Moreover, if I build a pure Spark implementation everything works even when referencing the SDK libraries as RSL.
    Does this indicate a bug in the globalplayer (flash player code)'s logic for handling UncaughtErrorEvents listeners within the loaderInfo hierarchy when the Flex SDK is Shared code between the SWFs?
    OR
    Since it works in Spark, is it an issue with how the flex2.compiler.mxml.Compiler turns MX based mxml components into generated AS classes (it hooks up the inline event listeners of child UIComponentDescriptor using a generic object and the click function is specified as a STRING and has to use untyped bracket notation to lookup on the UICompoent when adding it as a listener:
    new mx.core.UIComponentDescriptor({
                  type: mx.controls.Button
                  events: {
                    click: "___B_Button1_click"
                  propertiesFactory: function():Object { return {
                    label: "Throw Error"
    Where as Spark does this correctly and generates Factory functions for setting up child UIComponents when converting Spark component mxml to AS:
    private function _B_Button1_c() : spark.components.Button
        var temp : spark.components.Button = new spark.components.Button();
        temp.label = "Throw Error";
       temp.addEventListener("click", ___B_Button1_click);
        if (!temp.document) temp.document = this;
        mx.binding.BindingManager.executeBindings(this, "temp", temp);
        return temp;
    * @private
    public function ___B_Button1_click(event:flash.events.MouseEvent):void
        throwUncaughtError()
    Sadly, moving to pure Spark would be a big hit is my project's schedule and at this point and likely isn't feasible. I have examples (with view source) built in MX for both the RSL and MERGE cases, I just don't know how to attach them here.
    Sorry for the long comments and thanks again!

  • Suggestions for loading interactive graphs

    Working on an iPad only app that will require the client to be able to update using a CMS. One of the elements they had hoped to be able to add was various animated graphs that they had created in Flash and published as swf files.
    I am now aware that loading a swf file that includes actionscript is not permitted and will not work anyway.
    I am therefore seeking advice on alternative solutions. The animated graphs are all very different so there is no option to create a component and  just feed it data.
    Even if I could just somehow load the swf and add a stop action dynamically that may offer a solution.
    Any suggestsion most appreciated. I am curious as to how someone would deal with this scenario with an app created in Objective C - surely they would be faced with the same problems but not even have the luxury of being able to load in any swf files at all.

    Shot in the dark but you can import a web staged XML file into flash and then use that data on an iPad (have done this myself) Maybe you can bring in blank swfs with no code in them then have the CMS software export out an XML with the appropriate data. Then get them both into flash/app and pair up the data in the XML with the imported .swf file?

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

Maybe you are looking for

  • Activation and lack of information

    Hello. I am a new customer with BT and have signed up for phone line/broadband/TV. I appreciate that this is a customer to customer forum but I am posting to see if anyone has any insight as existing customers as I am now exhausted with talking to th

  • ORA-00257: archiver error. Connect internal only

    Hello everyone, On 10gR2, if we face the above error, the system would hang for some time. During this time no one will be able to connect. SYSDBA session will hang and wont give you SQL prompt quickly. I want to know if there is any way to remove th

  • Sitemesh and css problem

    Hi. I want to use SiteMesh to decorate various pages (jsp, html). I have a decorator, but i can't seem to link a css sheet to my pages. I have decorators.xml in /WEB-INF/ <?xml version="1.0" encoding="ISO-8859-1"?> <decorators defaultdir="/WEB-INF/de

  • Error in FSE3 - Financial Statement Version Display

    Hi, We have bee using Financial Statement Version DRL. But now the Client asked me to create another structure DRL1. I have created Financial Statement Version DRL1 in OB58. Now when i tried to Disply Financial Statement Version DRL1 in FSE3 transact

  • Error message 1935 on installation?

    happens every time I try to install adobe PS elemenst 10 from purchased dvds. Now wut?