haxe VS as3

1.Getters/Setters

AS3:

function get x():Number {
    return _x;
}
function set x(value:Number):Number {
    _x = value;
} 

Should be replaced to this:

public var x(getX, setY):Float
function getX ():Float
{
    return _x;
}

function setX (value:Float):Float
{
    return _x = value;
}
2.cast

AS3:

sprite as Sprite

Should be replaced to this:

cast(sprite, Sprite)

Where sprite is instance, Sprite is a class.

3.for each

AS3 For each loops

for each(var i:Item in items)
{
}

Should be ported to:

for (i in items)
{
}
4.for

AS3 Loops like this:

for (var i:int=0; i<10; ++i)
{
}

Should be ported to:

for (i in 0...10)
{
}
5.is

AS3 "is" like

(1 is Int)

Should be changed to

Std.is(1, Int)
6.Haxe doesn't support lower case imports like this:
import flash.utils.getQualifiedClassName;
import flash.utils.getTimer;
import flash.utils.setTimeout;

So convertor should remove imports and put in code those strings, like in this example:

AS3:

var a:int = getTimer();

Should be changed to:

var a:int = flash.utils.getTimer();
7.Convert Vector to Array

Replace Vector with Array

Vector.<Sprite>

To

Array<Sprite>
8.Change Vector arrays initializations to Array AS3 code like this:
var a:Vector.<MyClass> = new <MyClass> [new MyClass()];

To

var a:Array<MyClass> = new Array<MyClass>();
a.push(new MyClass());
9.Replace those dynamic params
function test (...params):void {

}

Change to:

function test (params:Array<Dynamic>) {

}
10.Final vars should be replaced with this tag
@:final
11.Events meta tags like this

AS3:

[Event(name="test",type="Foo")]

To:

@:meta(Event(name="test",type="Foo"))


from: 

http://haxe.org/doc/flash/usingas3classes/tarwins_as3_to_haxe_conversion_script https://github.com/as3boyan/tarwins_as3_to_haxe_conversion_script_-_haxe_neko_- http://haxe.org/doc/flash/usingas3classes/tarwins_as3_to_haxe_conversion_script

http://haxe.org/doc/flash/usingas3classes/tarwins_as3_to_haxe_conversion_script 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值