» Are you looking for FLV Player?

AS3: Hello World!

23 October 2005 | filed under flash, flex | no comments

There is this superstition that you should always create a “Hello World” program before anything else when learning a new programming language. So I did for ActionScript 3.0 and if you’re lazy, feel free to download the source code from my blog and compile your own Hello World! sample before it’s too late!

Actionscript:
  1. package {
  2.  
  3.     import flash.display.TextField;
  4.     import flash.display.MovieClip;
  5.  
  6.     public class HelloWorld extends MovieClip {
  7.  
  8.         public function HelloWorld () {
  9.  
  10.             var t:TextField = new TextField();
  11.             t.text = “Hello World!”;
  12.             addChild(t);
  13.         }
  14.     }
  15. }

FLEX Builder logo There’s one important tip that I can give you regarding this piece of code: when dynamically creating stage elements such as TextFields or MovieClips, they will remain invisible unless you actually assign them a place in the new DisplayList using, in this case, .addChild().

If you haven’t downloaded the FLEX 2.0 Builder alpha from Macromedia Labs yet, I highly recommend you do so right away.

One of the coolest things regarding the alpha is that it doesn’t just allow you to create FLEX 2.0 apps (which is cool anyway), you can also use it to program and compile for Flash Player 8.5!

 

Leave a Reply