原文地址:http://www.haxenme.org/developers/documentation/actionscript-developers/
为了避免以后要翻墙,先在这翻译备份一个:
haxe中包名小写,类名大写,上面是as3语法,下面是haxe语法

Basic Types
[code]
Boolean
int
Number
Object
void
Array
Vector.
Bool
Int
Float
Dynamic
Void
Array
Array

Package Declarations

package com.example.myapplication {

}
package com.example.myapplication;

Defining a Class

public class MyClass {

public function MyClass () {

}

}
class MyClass {

public function new () {

}

}

Loops

for (var i:uint = 0; i < 100; i++) { } for each (var value:String in items) { } for (var propertyName:String in object) { } for (i in 0...100) { } for (value in items) { } var fields = Reflect.fields (object); for (propertyName in fields) { } Switch Statements switch (value) { case 1: trace ("Equal to 1"); break; default: trace ("Not equal to 1"); break; } switch (value) { case 1: trace ("Equal to 1"); default: trace ("Not equal to 1"); } Type Inference var hi = "Hello World"; // type is Object // fails to compile in strict mode var hi = "Hello World"; // type is String // even works for code completion Type Casting var car:Car = vehicle as Car; var toString:String = String (10); var toNumber:Number = Number ("10"); var toInteger:int = int (10.1); var car:Car = cast vehicle; // or for a safe cast: var car = cast (vehicle, Car); var toString = Std.string (10); var toNumber = Std.parseFloat ("10"); var toInteger = Std.int (10.1); Type Details if (vehicle is Car) { } import flash.utils.getDefinitionByName; import flash.utils.getQualifiedClassName; name = getQualifiedClassName (vehicle); type = Class (getDefinitionByName (name); if (Std.is (vehicle, Car)) { } type = Type.getClass (vehicle); name = Type.getClassName (type); Checking for Null if (object == null) { } if (!object) { } if (object == null) { } Hash Tables var table:Object = new Object (); table["key"] = 100; trace (table.hasOwnProperty ("key")); for (var key:Object in table) { trace (key + " = " + table[key]); } delete table["key"]; var table = new Hash ();
table.set (“key”, 100);

trace (table.exists (“key”));

for (key in table.keys ()) {

trace (key + ” = ” + table.get (key));

}

table.remove (“key”);

Rest Parameters

function test (…params):void {

}

test (1, 2, 3);
function test (params:Array) {

}

Reflect.makeVarArgs (test) (1, 2, 3);

Reflection

var foo = object[“foo”];

bar.apply (this, [ “hi” ]);
var foo = Reflect.field (object, “foo”);

Reflect.callMethod (this, bar, [ “hi” ]);

Constants

private const gravity:Number = 9.8;
inline private static var gravity = 9.8;

Function Types

function hello (msg:String):void {

}

var type:Function = hello;
function hello (msg:String):Void {

}

var type:String->Void = hello;

// can also use Dynamic

Getters and Setters

function get x ():Number {

return _x;

}

function set x (value:Number):void {

_x = value;

}
public var x (getX, setX):Float;

function getX ():Float {

return _x;

}

function setX (value:Float):Float {

return _x = value;

}

Read-Only Properties

function get x ():Float {

return _x;

}
public var x (default, null):Float;

// null allows private access
// never would restrict all access
[/code]