"this" in as3

How would I do this in AS3? I want to call a function and run
it with specific properties depending on which button is clicked.
So how do the "_this" statement work in as3? in as2 I would write
something like this and "this" would stand for the instance
name:

You just call the same function when you set up your event
listener - and
then use the target property of the event to get which button
was clicked.
For instance, say you have two buttons on stage - instance
names a and b:
a.addEventListener(MouseEvent.CLICK, btnPressed);
b.addEventListener(MouseEvent.CLICK, btnPressed);
function btnPressed(e:MouseEvent){
trace(e.target.name);
e.target.y -= 10;
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

Similar Messages

  • Is this the best way to write this in AS3

    I have converted my old AS2 to As3. It now appears to work the same as before but being new to AS3 I have a few questions.
    In this example I click on a button which takes me to a keyframe that plays a MC. There is another btn that takes me back to the original page.
    In AS2 it is written like this.
    // Go to keyFrame btn
    on (release) {
    //Movieclip GotoAndStop Behavior
    this.gotoAndStop("Jpn_Scul_mc");
    //End Behavior
    // Play Movie
    on (release) {
    //Movieclip GotoAndStop Behavior
    this.gotoAndStop("Jpn_Movie");
    //End Behavior
    //load Movie Behavior
    if(this.mcContentHolder == Number(this.mcContentHolder)){
    loadMovieNum("PL_Japan_Scul.swf",this.mcContentHolder);
    } else {
    this.mcContentHolder.loadMovie("PL_Japan_Scul.swf");
    //End Behavior
    // Return key
    on (release) {
    //Movieclip GotoAndStop Behavior
    this.gotoAndStop("Jpn_Intro");
    //End Behavior
    In AS3 it is written like this.
    // Play Movie
    var myrequest_Jpn:URLRequest=new URLRequest("PL_Japan_Scul.swf");
    var myloader_Jpn:Loader=new Loader();
    myloader_Jpn.load(myrequest_Jpn);
    function movieLoaded_Jpn(myevent_Jpn:Event):void {
    stage.addChild(myloader_Jpn);
    var mycontent:MovieClip=myevent_Jpn.target.content;
    mycontent.x=20;
    mycontent.y=20;
    //unload method - Return to keyframe
    function Rtn_Jpn_Intro_(e:Event):void {
    gotoAndStop("Japan_Intro");
    Rtn_Jpn_Intro_btn.addEventListener(MouseEvent.CLICK, removeMovie_Jpn);
    function removeMovie_Jpn(myevent_Jpn:MouseEvent):void {
    myloader_Jpn.unload();
    myloader_Jpn.contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded_Jpn);
    Rtn_Jpn_Intro_btn.addEventListener("click",Rtn_Jpn_Intro_);
    // Go to keyFrame btn
    function Scul_Play(e:Event):void {
    gotoAndStop("Jpn_Scul_mc");
    Jpn_Scul_btn.addEventListener("click",Scul_Play);
    1. Is there a better, more efficient way to achieve this in AS3?
    2. I have used an //unload method in the AS3 script which does remove the MC from the scene but I notice in the output tab my variable code is still being counted for the last MC played.
    Is this normal?

    Hi Andrei, I have started a new project and taken your advice to construct it with a different architecture with all the code in one place.
    I have two questions regarding your last code update.
    var myrequest_Jpn:URLRequest;
    var myloader_Jpn:Loader;
    Rtn_Jpn_Intro_btn.addEventListener(MouseEvent.CLICK, removeMovie_Jpn);
    Jpn_Scul_btn.addEventListener(MouseEvent.CLICK, Scul_Play);
    function Scul_Play(e:MouseEvent):void {
         myrequest_Jpn = new URLRequest("PL_Japan_Scul.swf");
         myloader_Jpn = new Loader();
         myloader_Jpn.contentLoaderInfo.addEventListener(Event.COMPLETE, movieLoaded_Jpn);
         myloader_Jpn.load(myrequest_Jpn);
    function movieLoaded_Jpn(e:Event):void {
         // remove listener
         myevent_Jpn.target.removeEventListener(Event.COMPLETE, movieLoaded_Jpn);
         this.addChild(myloader_Jpn);
         myloader_Jpn.x = 20;
         myloader_Jpn.y = 20;
         // remove objects that are in "Japan_Intro" frame
    function removeMovie_Jpn(e:MouseEvent):void {
         // add back objects that are in "Japan_Intro" frame
         // remove from display list
         this.removeChild(myloader_Jpn);
         myloader_Jpn.unload();
         myloader_Jpn = null;
         // this moved from Rtn_Jpn_Intro_ function
         //gotoAndStop("Japan_Intro");
    Its all works great except for the line to remove event..
    1.
    myevent_Jpn.target.removeEventListener(Event.COMPLETE, movieLoaded_Jpn);
    I get an error:   1120: Access of undefined property myevent_Jpn.
    Removing this statement allows the code to work but that is not a solution.
    2.
    Rtn_Jpn_Intro_btn.addEventListener(MouseEvent.CLICK, removeMovie_Jpn);
    I would like this button to remove more than one movie. Is this possible.
    Thanks for the help todate.

  • The scope of this in AS3

    Hi
    I am just trying to understand the scope of this in AS3 for
    example in AS2
    basicM_btn.onRelease = function() {
    this._visible = false;
    Would have made the button invisible
    In AS3 I was expecting to write the same thing as this
    function clickHandler(event:MouseEvent):void {
    this.visible = false;
    menuA_btn.addEventListener(MouseEvent.CLICK, clickHandler);
    However this sets all of the content on the stage to visible
    = false
    Is there a difference in the way that this works in AS3
    Thanks for your help

    You want the event's target - not this...
    try this:
    function clickHandler(event:MouseEvent):void {
    event.target.visible = false;
    Dave -
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • How to add stop button in this code AS3

    Hello, im new to this adobe flash AS3. i want to create a simple play sound using flash + XML file for wbesite., this is my code
    all this code are working greate.. but i have the problem to add stop_btn code my playlist button already have pause, prevous and next and play.. only stop button i have fail to create. this is my code
    var my_songs:XMLList;
    var my_total:Number;
    var my_sound:Sound;
    var my_channel:SoundChannel;
    var current_song:Number = 0;
    var song_position:Number;
    var song_paused:Boolean;
    var myXMLLoader:URLLoader = new URLLoader();
    myXMLLoader.load(new URLRequest("playlist2.xml"));
    myXMLLoader.addEventListener(Event.COMPLETE, processXML);
    function processXML (e:Event):void{
    var myXML:XML = new XML(e.target.data);
    my_songs = myXML.SONG;
    my_total = my_songs.length();
    function playSong(mySong:Number):void{
    var myTitle = my_songs[mySong].@TITLE;
    var myArtist = my_songs[mySong].@ARTIST;
    var myURL = my_songs[mySong].@URL;
    title_txt.text = myTitle;
    artist_txt.text = myArtist;
    if (my_channel){
    my_channel.stop();
    my_sound = new Sound();
    my_sound.load(new URLRequest(myURL));
    my_channel = my_sound.play();
    my_channel.addEventListener(Event.SOUND_COMPLETE, onNext);
    next_btn.addEventListener(MouseEvent.CLICK, onNext);
    function onNext(e:Event):void{
    current_song++;
    if (current_song>=my_total){
    current_song=0;
    playSong(current_song);
    prev_btn.addEventListener(MouseEvent.CLICK, onPrev);
    function onPrev(e:MouseEvent):void{
    current_song--;
    if (current_song<0){
    current_song = my_total-1;
    playSong(current_song);
    pause_btn.addEventListener(MouseEvent.CLICK, onPause);
    function onPause(e:MouseEvent):void{
    if (my_channel){
    song_position = my_channel.position;
    my_channel.stop();
    song_paused=true;
    play_btn.addEventListener(MouseEvent.CLICK, onPlay);
    function onPlay(e:MouseEvent):void{
    if (song_paused){
    my_channel = my_sound.play(song_position);
    song_paused=false;
    } else if (!my_channel){
    playSong(current_song);
    can some one help with me... thank you

    stop_btn.addEventListener(MouseEvent.CLICK, onStop);
    function onStop(e:MouseEvent):void{
       if (my_channel){
          my_channel.stop();

  • How can I do this in AS3

    Hi?!
    Well... i AS2 when "set a function on
    event"(addEventListeneter like mouse click) i used 'this' to refer
    the 'mc' that i added the "function", but in AS3 it not work. If i
    use this, it calls the 'stage' that are acting...
    like:
    on AS2 (that works)
    mcCat.onRelease = function ()
    this.visible = false;
    on AS3 (that not has the same effect)
    mcCat.addEventListener(MouseEvent.MOUSE_OVER, mcCat_Hover);
    function mcCat_Hover(event:MouseEvent):void
    this.visible = false;
    How can i make the same effect that has in AS2 has in
    AS3?

    event.currentTarget.visible = false; works too.

  • Please help with this script, AS3 to AS2(preloader)

    Hi. Ive made a flash banner for my client. It have two scenes, preloader (with percentage and animation (in 100 frame)) and the main scene. Preloader uses AS3. I need this convert to AS2. How to do this? The code:
    import flash.events.ProgressEvent;
    function update(e:ProgressEvent):void
    var percent:Number = Math.floor( (e.bytesLoaded*100)/e.bytesTotal );
    if(preloaderMC is MovieClip){
    preloaderMC.gotoAndStop(percent);
    preload_txt.text = String(percent) + "%";
    if(percent == 100){
    play();
    loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);
    // Extra test for IE
    var percent:Number = Math.floor( (this.loaderInfo.bytesLoaded*100)/this.loaderInfo.bytesTotal );
    if(percent == 100){
    nextFrame();
    stop();
    The full FLA: http://www.agroinvent.eu/briklis.fla, if someone can repair(make) it, pls send me the corrected fla file.
    BIG THANKS. BEST REGARDS. Zolee

    use:
    var tl:MovieClip=this;
    function update():Void
    var percent:Number = Math.floor( (tl.getBytesLoaded()*100)/tl.getBytesTotal() );
    preloaderMC.gotoAndStop(percent);
    preload_txt.text = String(percent) + "%";
    if(percent == 100){
    clearInterval(preloadI);
    tl.play();
    clearInterval(preloadI);
    preloadI = setInterval(update,100);
    stop();

  • What's wrong with this code (AS3)?

    I want to publish a live stream and, when a button is pressed, publish the same stream for vod.  I haven't been able to get an answer as to whether I can do this...my code is below.  Can someone please tell me if I can do this, or what may be wrong with my code?
    The live stream and playback works fine; but the recording doesn't start.  Also, I want other objects on the client, such as the current camera and audio information, and the aspect ratio being used.  I havent' been able to get these to show up (i.e., the incomingLbl and outgoingLbl do not show up).
    Thank you,
    Phillip A
    My code:
    package {
        import flash.display.MovieClip;
        import flash.net.NetConnection;
        import flash.events.NetStatusEvent; 
        import flash.events.MouseEvent;
        import flash.events.AsyncErrorEvent;
        import flash.net.NetStream;
        import flash.media.Video;
        import flash.media.Camera;
        import flash.media.Microphone;
        import fl.controls.Button;
        import fl.controls.Label;
        import fl.controls.TextArea;
        import fl.controls.CheckBox;
        public class vodcast1 extends MovieClip {
            private var nc:NetConnection;
            private var nc2:NetConnection;
            private var ns:NetStream;
            private var ns2:NetStream;
            private var nsPlayer:NetStream;
            private var vid:Video;
            private var vidPlayer:Video;
            private var cam:Camera;
            private var mic:Microphone;
            private var camr:Camera;
            private var micr:Microphone;
            private var clearBtn:Button;
            private var startRecordBtn:Button;
            private var outgoingLbl:Label;
            private var incomingLbl:Label;
            private var myMetadata:Object;
            private var outputWindow:TextArea;
            private var cb1:CheckBox;
            public function vodcast1(){
                setupUI();
                nc = new NetConnection();
                nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nc.connect("rtmp://localhost/publishLive");
                nc2 = new NetConnection();
                nc2.connect("rtmp://localhost/vod/videos");
                nc2.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus2);
            private function startRecordHandler(event:MouseEvent):void {
                publishRecordStream();
            private function onNetStatus(event:NetStatusEvent):void {
                trace(event.target + ": " + event.info.code);
                switch (event.info.code)
                    case "NetConnection.Connect.Success":
                        trace("Congratulations! you're connected to live");
                        publishCamera();
                        displayPublishingVideo();
                        displayPlaybackVideo();
                        break;
                    case "NetStream.Publish.Start":
            // NetStatus handler for Record stream       
            private function onNetStatus2(event:NetStatusEvent):void {
                trace(event.target + ": " + event.info.code);
                switch (event.info.code)
                    case "NetConnection.Connect.Success":
                        trace("Congratulations! you're connected to vod");                   
                        break;
                    case "NetConnection.Connect.Rejected":
                    case "NetConnection.Connect.Failed":
                    trace ("Oops! the connection was rejected");
                        break;
                    case "NetStream.Publish.Start":
                        sendMetadata();
                        break;
            private function asyncErrorHandler(event:AsyncErrorEvent):void {
                trace(event.text);
            private function sendMetadata():void {
                trace("sendMetaData() called")
                myMetadata = new Object();
                myMetadata.customProp = "Recording in progress";
                ns.send("@setDataFrame", "onMetaData", myMetadata);
            private function publishRecordStream():void {
                camr = Camera.getCamera();
                micr = Microphone.getMicrophone();
                ns2 = new NetStream(nc2);
                ns2.client = new Object();
                ns2.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus2);
                ns2.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                ns2.attachCamera(camr);
                ns2.attachAudio(micr);
                ns2.publish("vodstream", "record");           
            private function publishCamera():void {
                cam = Camera.getCamera();
                mic = Microphone.getMicrophone();
                ns = new NetStream(nc);
                ns.client = this;
                ns.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                ns.attachCamera(cam);
                ns.attachAudio(mic);
                ns.publish("livestream", "live");
            private function displayPublishingVideo():void {
                vid = new Video(cam.width, cam.height);
                vid.x = 10;
                vid.y = 30;
                vid.attachCamera(cam);
                addChild(vid); 
            private function displayPlaybackVideo():void {
                nsPlayer = new NetStream(nc);
                nsPlayer.client = this;
                nsPlayer.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
                nsPlayer.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
                nsPlayer.play("livestream");
                vidPlayer = new Video(cam.width, cam.height);
                vidPlayer.x = cam.width + 100;
                vidPlayer.y = 30;
                vidPlayer.attachNetStream(nsPlayer);
                addChild(vidPlayer);
            private function setupUI():void {
                outputWindow = new TextArea();
                outputWindow.move(250, 175);
                outputWindow.width = 200;
                outputWindow.height = 50;
                outgoingLbl = new Label();
                incomingLbl = new Label();
                outgoingLbl.width = 100;
                incomingLbl.width = 100;
                outgoingLbl.text = "Publishing Stream";
                incomingLbl.text = "Playback Stream";
                outgoingLbl.move(20, 200);
                incomingLbl.move(300, 200);
                outgoingLbl.condenseWhite = true;
                incomingLbl.condenseWhite = true;
                startRecordBtn = new Button();
                startRecordBtn.width = 150;
                startRecordBtn.move(250, 345);
                startRecordBtn.label = "Start Recording";
                startRecordBtn.addEventListener(MouseEvent.CLICK, startRecordHandler);
                //cb1 = new CheckBox();
                //cb1.label = "Record";
                //cb1.move(135,300);
                //cb1.addEventListener(MouseEvent.CLICK,publishRecordStream);
                //clearBtn = new Button();
    //            clearBtn.width = 100;
    //            clearBtn.move(135,345);
    //            clearBtn.label = "Clear Metadata";
    //            clearBtn.addEventListener(MouseEvent.CLICK, clearHandler);
                addChild(outgoingLbl);
                addChild(incomingLbl);
    //            addChild(clearBtn);
                addChild(startRecordBtn);
    //            addChild(cb1);
                addChild(outputWindow);
            public function onMetaData(info:Object):void {
                outputWindow.appendText(info.customProp);

    use event.currentTarget (and you don't need to repeatedly define the same function):
    var c:int;
    var buttonName:String;
    for (c = 1;c < 5;c++) {
         buttonNum = "button"+c;
         this[buttonNum].addEventListener(MouseEvent.MOUSE_DOWN, pressStepButton);
    function pressStepButton(event:MouseEvent) {          trace(event.currentTarget,event.currentTarget.name);     }

  • Can anyone translate this to AS3 from AS2

    var my_btm = new flash.display.BitmapData(215, 110, true, 16777215);
    gradient_mc.start_offset = [];
    gradient_mc.finish_offset = [];
    var c = 0;
    while (c < 3)
        gradient_mc.start_offset[c] = {x: 0, y: 0};
        gradient_mc.finish_offset[c] = {x: Math.random() * 10 - 2, y: Math.random() * 3 + 4};
        ++c;
    gradient_mc.onEnterFrame = function ()
        var __reg2 = 0;
        while (__reg2 < 3)
            this.start_offset[__reg2].x = this.start_offset[__reg2].x + this.finish_offset[__reg2].x;
            this.start_offset[__reg2].y = this.start_offset[__reg2].y + this.finish_offset[__reg2].y;
            ++__reg2;
        my_btm.perlinNoise(20, 30, 5, 2, true, true, 0, true, this.start_offset);
        var __reg3 = new flash.filters.DisplacementMapFilter(my_btm, new flash.geom.Point(250, 0), 10, 1, 0, 30, "clamp");
        this.filters = [__reg3];
    ;

    I'll do my best:
    import flash.display.BitmapData;
    import flash.filters.DisplacementMapFilter;
    var my_btm:BitmapData = new BitmapData(215, 110, true, 16777215);
    gradient_mc.start_offset = [];
    gradient_mc.finish_offset = [];
    var c:uint = 0;
    while (c < 3)
        gradient_mc.start_offset[c] = {x: 0, y: 0};
        gradient_mc.finish_offset[c] = {x: Math.random() * 10 - 2, y: Math.random() * 3 + 4};
        ++c;
    gradient_mc.addEventListener(Event.ENTER_FRAME,doEnterFrame);
    function doEnterFrame(e:Event):void {
        var __reg2:uint = 0;
        while (__reg2 < 3)
            this.start_offset[__reg2].x = this.start_offset[__reg2].x + this.finish_offset[__reg2].x;
            this.start_offset[__reg2].y = this.start_offset[__reg2].y + this.finish_offset[__reg2].y;
            ++__reg2;
        my_btm.perlinNoise(20, 30, 5, 2, true, true, 0, true, this.start_offset);
        var __reg3:DisplacementMapFilter = new DisplacementMapFilter(my_btm, new flash.geom.Point(250, 0), 10, 1, 0, 30, "clamp");
        this.filters = [__reg3];
    A word of warning: I am not familiar with everything used in this example, so I do not guarantee 100% accuracy.  I did the basics, though, changing events to event listeners, and strictly typing all variables.
    I assumed that gradient_mc is a movie clip on the stage with the instance name "gradient_mc"

  • Is this possible in AS3?????  AS3 commercial application with speech, avatar real-time animation and innovative GUI

    Hi,
    Check out this awesome AS3 application from Umanify:
    http://www.icex.es/icex/cda/views_icexv3/asistenteVoz/asistenteVoz/0,6457,,00.html
    You can drag&drop the GUI of the assistant on the web
    page with the mouse...they are using transparent layers...and the
    avatar animation is lipsync with the speech....even they can copy
    and paste text from the web page and read it aloud with "lee"
    button...
    are those features possible in real-time with AS3??????
    how???

    Hi,
    Check out this awesome AS3 application from Umanify:
    http://www.icex.es/icex/cda/views_icexv3/asistenteVoz/asistenteVoz/0,6457,,00.html
    You can drag&drop the GUI of the assistant on the web
    page with the mouse...they are using transparent layers...and the
    avatar animation is lipsync with the speech....even they can copy
    and paste text from the web page and read it aloud with "lee"
    button...
    are those features possible in real-time with AS3??????
    how???

  • What is mean this words in as3

    i am new to as3 please help me about this words and how can i use it
    _root
    Math.atan2
    onEnterFrame
    Math.sqrt
    and the word " this " in as3
    *and what is the difference between this words ?
    _x and x
    _xmouse and mouseX
    _rotation and rotation

    _root (as2) = MovieClip(root)  (as3)
    Math.atan2 (as2) = Math.atan2 (as3)
    onEnterFrame (as2) = addEventListener(Event.ENTER_FRAME,somefunction);
    Math.sqrt (as2) = Math.sqrt (as3)
    this (as2) = this (as3)
    _x (as2) =  x (as3)
    _xmouse (as2) =  mouseX (as3)
    _rotation (as2) =  rotation (as3)

  • How to use as3 in flash cs3 to add dynamic text from a text file into a flash file

    let me start out by saying today is my first day of scripting
    in flash.
    I have a text file text.txt
    it contains
    text1=hello world
    can someone please show me how to display this text in a
    flash file
    i have been searching for this for hours and there are
    solutions with flash mx and actionscript 2.0 but i would like to
    see how to do this in as3.
    just a simple frame that loads that file and displays it when
    you test run the program
    much apreciated
    RC

    I'm not up on AS3 yet, but many things are still similar. You
    need to use the LoadVars class to accomplish this, You can find
    information this in Flahs Help>Actionscript>Actionscript
    Language Reference>Actionscript classes.
    rem: the text.txt file and the text.fla file must be in the
    same directory.
    The code will look something like this:

  • Migrate existing code of AS3 to AS2 - URLRequest, URLLoader

    Hi,
    I have written code to read an XML file by using URLRequest and URLLoader in ActionScript 3.0. Code is pasted below. This runs well in AS3.  Problem I am facing is because I wrote this in AS3, I am not able to use the DateChooser component in another part of the flash module because it seems like DateChooser component is not supported in AS3. So I want to migrate my below AS3 code back to AS2.
    **** Code in AS3 (I need help in writing equivalent code in AS2) :-
    var xmlText:XML ;
    var xmlReq:URLRequest = new URLRequest("myFile.xml");
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.load(xmlReq);
    xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
    function xmlLoaded(event:Event):void
        xmlText = new XML(xmlLoader.data);  
        info_txt.htmlText = xmlText.someTag ;
    **** I cannot use the above as is because, when I change the publish settings from AS3 to AS2, I get following errors -
    The class or interface 'URLRequest' could not be loaded.
    The class or interface 'URLLoader' could not be loaded.
    The class or interface 'Event' could not be loaded.
    Same works well in AS3. What should I do to make this work in AS2 or can anyone direct me in writing an equivalent in AS2.
    Please assist.
    Thanks in advance.
    MG

    parsing is done using the xmlnode methods and properties.  how you parse an xml file (in as2) depends on its structure.  but generally, you use firstChild, nextSibling, childNodes and nodeValue in the appropriate sequence to extact data.  the flash help files have sample code.  for tutorials, check google.
    if you're trying to load a cross-domain xml file, you'll have a cross-domain security issue to deal with.

  • Stop(); Action doesn't work in AS3?

    I'm a designer and usually work in AS2.
    But I created a movie in as3 (to use the Bones function), and now my stop actions are not working.
    What I usually do for my movies is break the movie down in parts on the Main timeline (Start/Content/End), place stops on each of these frames.
    And within the Movieclips that play on these labels I put a call:
    stop();
    _root.gotoAndPlay("Content") etc...
    Anyways any fixes for this in AS3?
    I'm using CS4 if that matters.

    The stop() command works as well in AS3 as it does in AS1/2.  What doesn't work is using AS2 terms like "_root".  In general, if a stop() command is not working it is because some other code is failing or otherwise overriding the stop().

  • AS3: No variables in testing environment

    So one of the ways I work is to publish my swf into the
    testing environment. If things are quite what I expect I often go
    to the Debug menu and select "List Variables." Then I can see the
    status of all my variables and often realize what is going on.
    Try this with AS3.
    Make a new AS3 FLA.
    On the first frame put this.
    var myVal:Number=10;
    Publish and then List Variables.
    Do you get anything other than:
    Level #0:
    Variable _level0.$version = "MAC 9,0,45,0"
    That is all I ever see. Not so useful.
    Was this just a bad habit to develop? Or is this something
    missing from AS3?

    I am sorry but List Variables is not supported for
    ActionScript 3.
    The Flash player has no way of identifying whether the movie
    being tested is
    ActionScript 1 and 2 where it is supported or ActionScript 3
    where it is
    not, so the feature still remains accessible for both even
    though it will
    only work for ActionScript 1 and 2.
    "Rothrock" <[email protected]> wrote in
    message
    news:f221t4$rlv$[email protected]..
    > So one of the ways I work is to publish my swf into the
    testing
    > environment. If
    > things are quite what I expect I often go to the Debug
    menu and select
    > "List
    > Variables." Then I can see the status of all my
    variables and often
    > realize
    > what is going on.
    >
    > Try this with AS3.
    >
    > Make a new AS3 FLA.
    > On the first frame put this.
    > var myVal:Number=10;
    > Publish and then List Variables.
    >
    > Do you get anything other than:
    >
    > Level #0:
    > Variable _level0.$version = "MAC 9,0,45,0"
    >
    > That is all I ever see. Not so useful.
    >
    > Was this just a bad habit to develop? Or is this
    something missing from
    > AS3?
    >

  • Getting time elapsed in AS3

    I have some asynchronous stuff going on in my Flash movie and
    would like to determine how much time elapses between two events --
    e.g., a button click and the response from a socket server.
    I'm wondering how to go about this in AS3?

    Thanks for your response!
    I took your advice on using getTimer() and it's working
    swell. However, I was kind of hoping for something that didn't
    require my Flash movie to be running the whole time. I have learned
    that you can create a new Date object and access its time property
    and that will return a value in milliseconds. You can later create
    a new Date object, access its time property, and compare the two:
    var start:Date = new Date();
    trace('start:' + start.time);
    //calculate PI to a million digits or whatever
    var end:Date = new Date();
    trace('time elapsed:' + (end.time - start.time));
    I haven't tested that, but I think it'll work.

Maybe you are looking for