Code to do a completely external actionscript 3 file?

If it's not too much trouble, could somebody post an actionscript .as file that would draw a rectangle on the flash stage, with the ONLY thing in Flash being the property assignment that you have to do.
I'm really new to this, and I have not been able to find any tutorials on this topic (other than someone telling me that the tutorials are out there).  I want to start hacking around with Actionscript and Flash, but I'm really frustrated because I can't get started.
I DON"T want to put code in the timeline, use code snippets, or use the actions window.
References to specific tutorials would be really appreciated.
Thanks!

Here is a class that draws rectangle:
package
     import flash.display.Graphics;
     import flash.display.Shape;
     import flash.display.Sprite;
     import flash.events.Event;
     public class ObjectWithRectangle extends Sprite
          public var fillColor:uint = 0xff0000;
          public var strokeColor:uint = 0x00ff00;
          public var rWidth:Number = 100;
          public var rHeight:Number = 100;
          public function ObjectWithRectangle()
               if (stage) init();
               else addEventListener(Event.ADDED_TO_STAGE, init);
          private function init(e:Event = null):void
               removeEventListener(Event.ADDED_TO_STAGE, init);
               var rectangle:Shape = new Shape();
               var g:Graphics = rectangle.graphics;
               g.lineStyle(1, strokeColor);
               g.beginFill(fillColor);
               g.drawRect(0, 0, rWidth, rHeight);
               g.endFill();
               addChild(rectangle);
Here is a class that implements the above class - if you make it a document class is Flash IDE - it will show a rectangle with random colors:
package
     import flash.display.Sprite;
     import flash.events.Event;
     public class DocClass extends Sprite
          public function DocClass()
               if (stage) init();
               else addEventListener(Event.ADDED_TO_STAGE, init);
          private function init(e:Event = null):void
               removeEventListener(Event.ADDED_TO_STAGE, init);
               var rect:ObjectWithRectangle = new ObjectWithRectangle();
               rect.fillColor = 0xffffff * Math.random();
               rect.strokeColor = 0xffffff * Math.random();
               rect.rWidth = 200;
               rect.rHeight = 250;
               addChild(rect);

Similar Messages

  • 'Basic' external actionscript file/class usage

    Hey All,
    I'm a bit baffled by something that should, in my humble opinion, be a piece of cake...
    The setup is really easy. A simple application with a single textinput, a button and a text component.
    When the button is clicked a function is called that sets the text from the inputfield to the text component.
    code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Script>
            <![CDATA[
                public function click(inputText:String):void {
                    outPutTxt.text = inputText;
            ]]>
        </mx:Script>
        <mx:TextInput x="10" y="10" id="inputTxt"/>
        <mx:Button x="178" y="10" label="Button" id="Btn" click="{click(inputTxt.text)}"/>
        <mx:Text x="251" y="12" text="Text" id="outPutTxt"/>
    </mx:Application>
    As I said, really easy.
    What I want to do is put the function 'click' into an external actionscript file or class. And still be able to, from within the external file, modify the outPutTxt stuff.
    I'm aware that I could create a public bindable variable inside of the external file and then bind the outPutTxt to that variable, but I would really like to be able to 'simply' force the value...
    Is that possible? If yes: how plix
    If it's not possible, I'd like to know as well! And in that case, how would I then re-use the same instance of a class/file in multiple seperate components? Say I got a 'login' thingie where a user logs in (data stored externally in a seperate actionscript file/class) and I want to re-use that information on other pages... Or is this done automatically?
    Any and all comments/answers are higly appreciated!
    Pieter

    Hey Levancho,
    thanks for your answer!! Much appreciated.
    However, the code you proposed threw an error...
    Errormessage:
    ReferenceError: Error #1069: Property outPutTxt not found on controls.Control and there is no default value.
        at controls::Control/btnClick()[C:\...\FlexTest_03\src\controls\Control.as:13]
        at FlexTest_03/__Btn_click()[C:\...\FlexTest_03\src\FlexTest_03.mxml:11]
    So I tried something else where I bind the text in my OutPutTxt to a variable inside of the external class file.
    Code:
    Class:
    package controls
        public class Control
            [Bindable]
            public var outPutText:String = "";
            public function Control()
            public function btnClick(inputText:String):void {
                this.outPutText =  inputText;
    Mxml:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Script>
            <![CDATA[
                import controls.Control;
                [Bindable]
                private var control:Control = new Control();
            ]]>
        </mx:Script>
        <mx:TextInput x="10" y="10" id="inputTxt"/>
        <mx:Button x="178" y="10" label="Button" id="Btn" click="{control.btnClick(inputTxt.text)}"/>
        <mx:Text x="251" y="12" id="outPutTxt" text="{control.outPutText}"/>
    </mx:Application>
    And this basically did what I wanted to do... so I just need to do some major binding between my application and the classes I'll be using for my business logic.
    Now for something else entirely...
    Is there a way for me to pass the instance of my class between flex components?
    Pieter

  • External actionscript file

    Hi, I've more than two components accessing the same
    function. Hence, I would like the function to be on an external
    actionscript file.
    My codes are as followed:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:HDividedBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="100%" height="100%">
    <mx:Metadata>
    [Event(name="scaleChange",
    type="actionscripts.sliderChange")]
    </mx:Metadata>
    <mx:Script>
    <![CDATA[
    import actionscripts.sliderChange;
    import mx.managers.DragManager;
    import mx.core.DragSource;
    import mx.events.DragEvent;
    import flash.events.MouseEvent;
    import mx.containers.Box;
    [Bindable]
    [Embed(source="/images/map.jpg")]
    public var map:Class;
    public var oWidth:Number = 2800; //original map width - 1200
    public var oHeight:Number = 2100; //original map height -
    900
    public var xOff:Number;
    public var yOff:Number;
    private function dragMap(event:Event):void{
    event.currentTarget.addEventListener(MouseEvent.MOUSE_DOWN,
    mouseMoveHandler);
    private function doDragEnter(event:DragEvent):void{
    DragManager.acceptDragDrop(Box(event.target));
    private function mouseMoveHandler(event:MouseEvent):void{
    event.currentTarget.useHandCursor=true;
    var dragInitiator:Image=Image(event.currentTarget);
    var ds:DragSource = new DragSource();
    ds.addData(event.currentTarget, 'img');
    var imageProxy:Image = new Image();
    imageProxy.source = map;
    xOff = event.currentTarget.mouseX;
    yOff = event.currentTarget.mouseY;
    DragManager.doDrag(dragInitiator, ds, event, imageProxy, 0,
    0, 0.00);
    private function doDragDrop(event:DragEvent):void{
    targetMap.x = event.currentTarget.mouseX - xOff;
    targetMap.y = event.currentTarget.mouseY - yOff;
    public function onSliderChange():void{
    var temp:Number = 100-scale.value;
    targetMap.width = temp/100*oWidth+1200;
    targetMap.height = temp/100*oHeight+900;
    map.smoothing = true;
    var nWidth:Number = targetMap.width;
    var nHeight:Number = targetMap.height;
    var sliderObj:sliderChange = new sliderChange(nWidth as
    Number,nHeight as Number,"scaleChange");
    dispatchEvent(sliderObj);
    ]]>
    </mx:Script>
    <mx:Canvas id="scaling" width="75%" height="100%">
    <mx:VBox width="100%" height="100%"
    horizontalAlign="center" verticalAlign="middle">
    <mx:Box id="mapContainer" width="500" height="500"
    horizontalAlign="center" verticalAlign="middle"
    horizontalScrollPolicy="off" verticalScrollPolicy="off"
    dragEnter="doDragEnter(event);" dragDrop="doDragDrop(event);">
    <mx:Image source="{map}" id="targetMap"
    scaleContent="true" creationComplete="dragMap(event);" />
    </mx:Box>
    <mx:HSlider id="scale" liveDragging="true" minimum="1"
    maximum="100" labels="['1','100']" width="500" height="30"
    change="onSliderChange()" />
    <mx:Text text="{scale.value.toFixed(2)} km" />
    </mx:VBox>
    </mx:Canvas>
    <mx:Canvas width="25%" height="100%"
    styleName="sideBar">
    <mx:Label text="test test" />
    </mx:Canvas>
    </mx:HDividedBox>
    How do I make the drag and drop functions in the
    <mx:Script></mx:Script> to be in an external
    actionscript file so that this component can access it for the drag
    and drop to work?
    Any help is very much appreciated. ^^

    You can reference a external actionscript file in a
    <mx:Script source="myScripts.as"/>
    I do not use it this way as it is not a vary OO way to do
    things.
    I will generally create a singleton class (so it is only
    instantiated once)
    and use it for utility type functions.
    For example:
    public class UtilityClass
    private static var _instance:UtilityClass;
    public function UtilityClass()
    public static function getInstance():UtilityClass
    if(_instance == null)
    _instance = new UtilityClass();
    return _instance;
    public function myFunction():void
    Then in a mxml
    <mx:list id="list"
    dragDrop="UtilityClass.getInstance().myfunction()"

  • External Actionscript File not being Included

    Odd problem:
    Myself and a colleague are working on a project. We're both
    using Flash 8. We've both downloaded the latest Flash player.
    The project involves a series of perfume bottles, all lined
    up in a row. When you press a key on the keyboard, the associate
    bottle enlarges and some info on it appears. At the same time the
    other bottles fade out (an alpha change).
    The alpha change is driven using an external actionscript
    file, which is called (#include) at the top of the first line of
    script in the ‘main’ movie.
    The problem is, when I publish the swf file, the alpha change
    doesn’t work. When my colleague publishes it, it works. Why
    is this? It’s almost as if in publishing from my computer,
    the external .AS file is being ignored.
    I’ve tried calling the .AS file using a full path to
    the file. No change.
    I’ve tried uninstalling and reinstalling the Flash
    player, and older version of the player. No change.
    Here’s something else that’s odd: I’ve
    tried copying all the script from the external .AS file and
    embedding it into the main movie. No change. Is it that the
    publishing from my computer is corrupted? Other things I’ve
    published recently have worked fine?
    Any ideas?

    Yes, I've opened the AS file, and it seems ok. I've also had
    it sent to me a couple of times in case it got corrupted in
    transit.
    I've also tried copying the script from the AS file and
    embedding it into the 'main' movie at the #include statement (and
    removing the #include statement) so it doesn't have to look for the
    AS file, but this hasn't helped.
    I'll try making a different AS file with the trace statement
    you suggested, but I have other movies that call external AS
    statements, and they work.
    We're both running XP Pro w/ SP2.

  • Flex 3 vs Flex 4 Preprocessor directives and code behind (External Actionscript file)

    I have a framework that I've built that I want to use on Flex3 and Flex4.
    I've added pre-processor directives as per this link (http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html) and got my Flex 4 code to compile nicely.
    I then went to flex 3 and discovered my sub-class of Application wouldn't compile because it was based off of spark. No problem, I'll add in a directive.
    Except now my overridden class has duplicate code, specific to which SDK it is using.
    No problem, I'll put all of the application class code in an Actionscript file and include it in both Application class declarations for each directive.
    It works nicely in Flex 3, so I went to Flex 4, tried to compile and now I'm getting compiler errors saying things such as "The (private|public|protected) attribute may only be used on class property definitions." and "The (private|public|protected) attribute can only be used inside a package.
    This same file works in Flex 3, but not in Flex 4.
    What can I do to make the code compile in both places?
    I'll work on a simple case so I can upload some code.

    Nevermind.
    I got around this issue by renaming my sub-classed Application to "...Application".
    Now I can use a directive to specify an import statement for the extends Application portion rather than specifiing the fully qualified spark.components.Application or mx.core.Application.
    Lame - but done.

  • How to import classes from an external actionscript file

    This is driving me crazy, I've been trying to resolve this on my own for ages, and I've reviewed a lot of different materials, but I still can't seem to just import some external actionscript classes correctly.
    I'm using Flash Builder 4 with the Flex 4 SDK on mac osx 10.6
    the class I'm trying to import (I'll call it DesiredClass) is in a folder like this
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    within the class itself, the package declaration looks like this (I left all the guts out for clarity):
    package com.foreignproject
        import flash.display.Sprite;
        public class DesiredClass extends Sprite
            public function DesiredClass()
    I'm working on a totally different actionscript file at
    /Users/username/Documents/Adobe Flash Builder 4/TestProject/src/TestProject.as
    in this file I try to import the DesiredClass:
    package
         import com.foreignproject.DesiredClass;
         import flash.display.Sprite;
         public class TestProject extends Sprite
              public function TestProject()
              var neatClass:DesiredClass = new DesiredClass();
    And then I try to add the class I want to the source path.
    I've tried adding each folder to the source path separately:
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    /libraries/com/foreignproject/com/foreignproject/DesiredClass.as
    If I choose the libraries folder or either of the com folders then an error shows up in theTestProject.as file, saying:
    Definition com.foreignproject:DesiredClass could not be found.
    But f I choose either of the foreignproject folders then an error shows up in theDesiredClass.as file saying:
    a file found in a source-path must have the same package structure 'com.foreignproject', as the definition's package, ".
    What am I doing wrong? Please help. I bought a book on actionscript, started doing the flex-in-a-week series, read numerous online discussion boards, and I still can't import these classes.
    Thanks in advance.

    I don't know if this method is supported anymore but you can give it a try.
    If you backed up bookmarks in IE using the following directions, you should be good!
    *In IE, "File -> Import and Export -> Export Cookies".
    *Open newly exported "cookies.txt" in a text editor and put a period before every line that starts with a domain. So a line starting with <b>altavista.com TRUE / FALSE 1388491200 AV_ALL 1</b> will become <b>.altavista.com TRUE / FALSE 1388491200 AV_ALL 1</b>
    *Then, move the "cookies.txt" file to your profile folder.
    You can get to the Profile folder two ways
    *Help > Troubleshooting Information > Profile Directory > Show Folder
    or
    *Go to '''about:support''' and click Show Folder next to Profile Directory.

  • JavaScript alert in AS3 or AS2 to debug the external actionscript file

    Hi,
    Is there any way to debug the external AS file as i dont want to use "trace".
    I have an idea to use the input text field the check the variable/function is working right but this is not enough so is there any process in AS2 or AS3.
    Thanks in advance..

    my mistake ..i have used there dynamic textfiled.
    but i got a easy solution by using
    getURL ("javascript:alert('Testing');");
    but this is not the good solution
    is there any way to import the alert contolls in AS2
    like i have read somewhere
    import mx.controls.Alert;
    Please reply..

  • How to pass data from external Actionscript file to MXML file

    HI...
    I do not know about the Application.application.whateverFieldIWantToReference and it does work on my computer, but only when the external .as file is in the same folder as the main .mxml application... But in my case, the .as file is in another folder (ie. package)...
    Also i want to know When I use the standard Application.application way, it does not spit out any error, but it just doesn't work either.
    Alternatively, I guess I could pass the field (in this case, a  TextArea) as an argument, but how do I do that? How to pass a  TextArea(or any other element, for that matter) as an argument? What  type is it?
    Does anybody know how to circumvent this? Any help is appreciated,
    Thanks.

    HI...
    I do not know about the Application.application.whateverFieldIWantToReference and it does work on my computer, but only when the external .as file is in the same folder as the main .mxml application... But in my case, the .as file is in another folder (ie. package)...
    Also i want to know When I use the standard Application.application way, it does not spit out any error, but it just doesn't work either.
    Alternatively, I guess I could pass the field (in this case, a  TextArea) as an argument, but how do I do that? How to pass a  TextArea(or any other element, for that matter) as an argument? What  type is it?
    Does anybody know how to circumvent this? Any help is appreciated,
    Thanks.

  • Why do button functions included in external actionscript not persist across frames?

    this one drives me nuts!
    if i include an external actionscript file in frame one of my
    movie, then [as you'd expect] all the functions, global variables
    etc contained in that external AS file are available throughout my
    movie - with one notable exception.
    if i add a button to the stage - in a frame other than frame
    one - whose onRelease handler is defined in the external AS, the
    function is not called when the button is clicked - i have to
    re-include the external AS file again on the frame in which the
    button resides, in order for the buttons function to be called.
    anyone know why this is - and if there's a way round it?
    how come all the other functions in the AS persist across all
    frames and all timelines in the movie, but the button handlers only
    seem to be available on the actual frame in which the AS file is
    included?
    download
    example

    I think you and I are dealing with similar issues and the
    root cause is referred to as "scope." The only difference between
    your and my problems is that your code is in an external as file
    and mine is on the timline. But in both instances, code that should
    work doesn't. Robert Reinhardt has covered this in an article at
    http://www.communitymx.com/content/article.cfm?cid=8E4DF.
    He is the author of the Flash Actionscript Bible series and so
    knows what he is talking about. I have been studying it for an hour
    and darn if I can understand the second page of it. I've asked for
    help myself about this at
    http://www.kirupa.com/forum/showthread.php?t=248316.

  • Calling a function in an external actionscript

    Hi. First of all I'd like to put my hands up and say that what I know about Flash is antiquated (I used to work with Flash 4 / 5), and have now been thrown into the deep end, as it were.
    I have an application that has a button component. In an external actionscript file there's an event listener that calls a function when this button is pressed. I want to replace the button with a graphic that switches according to whether the button is 'on' or 'off'. I've created a movie clip that cycles back and forth between the on and off states when clicked, but the trouble I'm having is getting it to call the function. I have no idea how to do it, other than to just include function_name(); (or call.function_name();) in the onRelease handler (which doesn't work). Is it possible to use event listners for movie clips (rather than components?) Or else how can I call this function? It should be really simple and I'm tearing my hair out trying to get it to work! The function is declared 'public', by the way...
    Oh yes, this is ActionScript 1 (I think...)
    Eternal thanks and gratitude to anyone who can help me...

    Do you mean to copy it here, or copy it into the fla? I've already tried doing the latter, which doesn't work - the script imports other external as files and I think that that's messing things up. The function only seems to work when it's located in this external file. The function I'm trying to call is
    public function toggleAudio() {
           //if (btnAudio.label == "Sound Off") {
           if (_root.audio == "mute" or btnAudio2.label == "Sound Off") {
               trace("toggleAudio AUDIO: Off");
               //btnAudio.label = "Sound On";
               _root.audio = "unmute";
                         // stop recieving audio from in stream
               ServiceLocator.getInstance().getService("nsService").returnInStream().receiveAudio(false) ;
               // stop sending audio on out stream
               ServiceLocator.getInstance().getService("nsService").returnOutStream().attachAudio(null);
                     } else {
               trace("toggleAudio AUDIO: On");
               btnAudio2.label = "Sound Off";
               _root.audio = "mute";
                         // start recieving audio from in stream
               ServiceLocator.getInstance().getService("nsService").returnInStream().receiveAudio(true);
               // start sending audio on out stream
               ServiceLocator.getInstance().getService("nsService").returnOutStream().attachAudio(Servic eLocator.getInstance().getService("camService").returnMic());
    The bit at the beginning where I've commented some stuff out is where I've been trying out different things to get it to work.
    For all intents and purposes though the function could be
    public function please_work() {
    trace("I work!");
    All I need is for a way to call this from the main flash movie

  • Variable created on click in edgeActions.js but want to reference it in external js file

    Hi, I created a variable on-click in edgeActions.js but want to reference it in external js file. This is where I am at so far:
    In my edgeActions.js I st a variable on compositionReady and then use it when I click on the symbol: questionMarkR1. This works fine.. the problem is that I don't know how to reference the variable in my external js file. This first code is working from the edgeActions.js:
    Symbol.bindElementAction(compId, symbolName, "document", "compositionReady", function(sym, e) {
             sym.setVariable("questionAsked", false); // sets the initial value
    Symbol.bindElementAction(compId, symbolName, "${_questionMarkR1}", "click", function(sym, e) {
             var questionAsked = sym.getVariable("questionAsked");
             alert(questionAsked);
             if (questionAsked)// if true
             sym.$("checkButton2").removeClass( "hidden" );
             sym.$("popUp").removeClass( "hidden" );
             else  //if false
             sym.$("pic2a").removeClass( "hidden" );
             sym.$("pic2b").removeClass( "hidden" );
             sym.$("pic2c").removeClass( "hidden" );
             sym.$("pic2d").removeClass( "hidden" );
             sym.$("closeBox").removeClass( "hidden" );
    This next part doesn't work because I don't know how to reference the variable correctly. This is what I have tried and it doesn't work:
         var questionAsked = sym.getComposition().getStage().getVariable("questionAsked");
         alert(questionAsked);

    Hi,
    Edge Animate exposes some API for external scripts, which  you will need to use in your case:
    For more info about the Edge Animate API, see Adobe Edge Animate CC JavaScript API
    Use the code as below in your external js file:
         var comp = AdobeEdge.getComposition("EDGE-606063631"); // replace "EDGE-606063631" with your comp id, you can find in the .html file
         var stage = comp.getStage();
         var questionAsked = stage.getVariable("questionAsked");
         alert(questionAsked);
    hth,
    Vivekuma

  • Loading external as file through url

    Hi
    I have external actionscript files that I call like this:
    #include "../events/allevents.as"
    But if I want to inport the full URL i.e.
    #include "http://www.essentialeventsmanagement.com/events/allevents.as" it does locate the file although it is the correct URL. How can I set this up so it always calls the server as and not my local as file
    Thanks
    Mark

    Ok thanks for clearing that up... is there a way to load this file dynamically?
    Thanks
    Mark

  • Exit Android App with external *actionscript.as* files

    Hi, i'm trying to make this code work with a application that got 99% of code driving by external actionscript.as files;
    In another app without any external call i mean no actionscript.as files, the code work very fine.
    My goal is to shutdown any activity of the app when the user receive a call or something like that;
    Many thanks in advance and sorry my english
    Scene 1, Layer 'Layer 1', Frame 1, Line 14
    1046: Type was not found or was not a compile-time constant: KeyboardEvent.
    function handleActivate(event:Event):void
        NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
    function handleDeactivate(event:Event):void
        NativeApplication.nativeApplication.exit();
    function handleKeys(event:KeyboardEvent):void        ----- Line 14 -----
        if (event.keyCode == Keyboard.BACK)
            NativeApplication.nativeApplication.exit();
    if (Capabilities.cpuArchitecture == "ARM")
        NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate, false, 0, true);
        NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate, false, 0, true);
        NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys, false, 0, true);

    Look Mr. Colin, added the import flash.events.KeyboardEvent; and thats what i got:
    Scene 1, Layer 'Layer 1', Frame 1,
    Access of undefined property:
    NativeApplication
    SystemIdleMode
    Keyboard
    Capabilities
    I'm addind this code inside Flash CS6, not via external.as

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

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

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

  • Writing code or text in an external file

    i want to write some text or code in an external file such as
    (text file or something else)
    when an event in flash occurs
    like (on mouse click)
    thanks for your answer

    Its important to know whether its plain text or code that
    you're expecting to execute. You can use something like the
    loadVars method to read a plain text or XML file. You could get
    variables from it to use in your code. But the movie will have been
    compiled already, so I don't think large blocks of code are
    appropriate here. That having been said, you can create external AS
    files that are compiled into your SWF.
    Hope that helps!

Maybe you are looking for

  • FAQ: How do I post photos to Facebook from Revel?

    Q: How do I post photos to Facebook from Revel? A: Sharing your images to Facebook If you have an iPad or iPhone Click, then first login to facebook on your device. Then, launch Revel, navigate to an album and click on the icon. Select the images you

  • When watching Youtube clips firefox causes windown blue screen - windows 7 on HP8540w

    Hi HP8540w laptop with Windows7 professional. when watching youtube clips windows crashes - blue screen of death! watching the same clips in Internet explorer doesn't cause a crash - isolated to Firefox.

  • File to IDoc : XML parsing in ABAP mapping

    Hi, In ABAP mapping I want to parse all of the incoming XML strings to internal table.Later I add few more fields to this table and transfer them to IDOC adapter in IDOC-XML format.In thsi case how do i get all of the input file data(converted from X

  • Payment block for ERS (MRRL) not working

    Dear SAP gurus, Payment block in case of ERS is nor working, we have set all the Tolerence limit, even set in vendor master as payment block as P Thanks in advance, Regards, Vinod

  • SQL Server 2012 in restoring mode

    Hi All, My database is in "restoring" mode and is taking forever to complete the activity. Need some help to get my db back. Regards, Abhinay Tharwal