Robots w/Lasers

February 21, 2007

AS3 Quickstart

This is a quick reference I wrote for getting started in writing Actionscript3 / Flash9 applications, using all free tools. Note that this is aimed at Windows users (FlashDevelop (the IDE) is a windows-only tool). Later I will write a version aimed at Linux users (The Flex 2 SDK (the actual compiler) is written in cross-platform Java).


FlashDevelop + AS3/Flex3

  • Install Flex 2 SDK
  • Follow the installation instructions from the download page. The summary is below, but may be out of date:
    • Download Flex 3 SDK – You want “Adobe Flex SDK” – Get “Milestone” for production code, “Stable” for some newer updates that is reasonably stable, and “Nightly” for alpha code with the latest features
    • After unzipping somewhere, go to Tools→Program Settings→AS3Context→Flex SDK Location and set the path
  • Do Project → New Project… and pick an Actionscript 3 project. To compile & run hit F5, to compile only hit F8. trace()'s will go to the Output window if you compile in Debug mode.
  • Check out the neat auto code generator – in a nutshell, put your cursor on something and hit ctrl+shift+1 (see link for details on what places it works)


Intro to AS3 Tutorials


PaperVision3D


Embedding assets in AS3

  • You can easily embed assets using the [Embed()] tag in your .as files.
  • NOTE: The path to the assets is relative to the .as file!
public class Main extends Sprite { 
  [Embed(source="logo.png")] 
  public var Logo:Class; 

 
  public function Main() { 
    var logo:Bitmap = new Logo(); 
    addChild(logo); 
  } 

}


Hello World

  • AS3 Hello World

    package { 
    	import flash.display.Sprite; 
    	import flash.text.TextField; 
     
    	[SWF(width="800", height="600", backgroundColor="#ffffff", frameRate="30")] 
    	public class HelloWorld extends Sprite { 
     
    		public function HelloWorld() { 
    			var display_txt:TextField = new TextField(); 
    			display_txt.text = "Hello World!"; 
    			addChild(display_txt); 
    		} 
    	} 
    }
  • MXML Hello World
    
    <?xml version="1.0" encoding="utf-8"?> 
    <!-- @mxmlc -default-size 400 300 --> 
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" > 
    	<mx:Script> 
    	<![CDATA[ 
    		import mx.controls.Alert; 
     
    		public function doAlert():void { 
    			Alert.show("You clicked the button!", "Hello Alert"); 
    		} 
    	]]> 
    	</mx:Script> 
     
    	<mx:VBox horizontalAlign="middle"> 
    		<mx:Label text="Hello World"/> 
    		<mx:Button label="click me!" click="doAlert()"/> 
    	</mx:VBox> 
    </mx:Application>
    
Filed under: — davr @ 1:51 pm

3 Comments »

  1. [...] & licensing – Own It Flash Tutorials | FlashGuru Consulting Vectors for Flash Tile based games Robots w/Lasers » AS3 Quickstart Asual » [...]

    Pingback by FlashBrighton » Blog Archive » Flash Links — November 20, 2007 @ 6:09 am

  2. Thank you for any other magnificent article. The place else may
    just anyone get that kind of info in such a perfect method of
    writing? I’ve a presentation subsequent week, and I am at the search for such information.

    Comment by best Gpt site — May 12, 2013 @ 1:17 pm

  3. Tremendous things here. I am very happy to peer your article.
    Thanks so much and I’m taking a look forward to touch you. Will you kindly drop me a mail?

    Comment by castle ville — May 19, 2013 @ 5:30 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress

Bad Behavior has blocked 2946 access attempts in the last 7 days.




Paid Advertisements
Guitar Lessons - Renegade Motorhome - Costa Rica - British Virgin Islands