as3 in haxe

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

as3 in haxe

Chris Ochs
Before I go down this path I want to make sure this will (in theory at
least) work.

I took a sizable as3 library and created haxe stubs for it.  I want to
create a haxe program that uses this library and run it under neko.
Will that work?  Or can I only target the flash platform using this
approach?

Chris

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: as3 in haxe

Adrian Cowan
No, that method will only work for the flash targets.

,
Adrian

On Mon, Jun 20, 2011 at 4:38 PM, Chris Ochs <[hidden email]> wrote:
Before I go down this path I want to make sure this will (in theory at
least) work.

I took a sizable as3 library and created haxe stubs for it.  I want to
create a haxe program that uses this library and run it under neko.
Will that work?  Or can I only target the flash platform using this
approach?

Chris

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: as3 in haxe

Alex Liebert
I believe there's a script or two (google) for converging as3 to haxe, but they might not do the whole job.  It's a starting point though.

My suggestion would be:

Write unit tests (or convert ones you already have) in haxe.  It's an easy transition to make from as3 and it will familiar with some of the differences.  Search haxe.org for unit test, the basics like Assert are built in for you.

Take your existing tamarin target as3 code, and preprocess it with a script from the internet, or just start porting.  Work until the unit tests pass.

Although there's no straight built in way to convert as3 to haxe, the haxe compiler does have an option to generate as3 code from haxe source.  So if it turns out you like haxe but neko's not for you, you can run that and should still be able to use your new work.

Alex

On Sun, Jun 19, 2011 at 11:53 PM, Adrian Cowan <[hidden email]> wrote:
No, that method will only work for the flash targets.

,
Adrian


On Mon, Jun 20, 2011 at 4:38 PM, Chris Ochs <[hidden email]> wrote:
Before I go down this path I want to make sure this will (in theory at
least) work.

I took a sizable as3 library and created haxe stubs for it.  I want to
create a haxe program that uses this library and run it under neko.
Will that work?  Or can I only target the flash platform using this
approach?

Chris

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: as3 in haxe

jlm@justinfront.net
In reply to this post by Chris Ochs
No you need to port the code, you can use tools they are links on the  
wiki to partially do it, but here's some tips for doing it by hand.

For most stuff as3 to haXe is quite easy.  You can do a lot with  
search and replace.
public class to class
Number to Float
Boolean to Bool
int and uint to Int

get space to get_
set space to set_
then add in a var ( get_, set_ ): returnType
then add a return value to the set_ function
if the gets and sets don't do anything seriously consider just making  
the property public and not using getters and setters, also maybe move  
to using get functions rather than getters.

then you can shift negative tab in and remove the main brackets.
probably the biggest pain is the array access can't be abused on  
everything in haXe, so you sometimes have to start putting in set's  
and get's for stuff like dictionary access.  And you have to get  
stricter on basic type structures, so

Array's need to be typed
Array<Float>

functions are often
Void -> Void
or maybe
Event -> Void

although most void's in as3 can just be removed from the end of methods.

from methods you can remove much of the typing of local variables, it  
cleans up the code a lot for reading.

static const  normally becomes inline static var

initialising instance variables needs to be done in the constructor  
and can't be done when declared, but that is normally fairly simple  
copy the offending and some deleting.

for loops can be replaced fairly easily
for( var i: Int = 0; i < len; i++ )     goes to    for( i in 0...len )

remove breaks from switch statements

look at 'using' for stuff like EReg

probably have to use Std.int, Std.string etc... more than in flash and  
sometimes case( anInstance ,castType ) or cast( anInstance ) to make  
sure you using proper type, but sometimes that is just for the  
compiler, but it will catch more errors.

I am not sure how extensive nme really is for neko so you may need to  
rewrite loading aspects and maybe start with trying to get haXe flash  
working and then 'remap' flash to 'nme'

In terms of tools best off on windows 32bit running flashdevelop,  
other setups work but if you have a choice then this is probably best,  
unless you love textmate like I do :)

in haXe you can have a private constructor which is good if your using  
a singleton.

I think you can swap tweenmax for acurate( ? spelling ) or with more  
work feffect, you can swap signals for hsl or hxs.

you can't use   ||=  or &= .

for optional  parameters to functions you need to add "?"

Hope that helps get you started on hand porting, really it is not hard  
unless you have been too clever.


Cheers

;j


On 20 Jun 2011, at 08:38, Chris Ochs wrote:

> Before I go down this path I want to make sure this will (in theory at
> least) work.
>
> I took a sizable as3 library and created haxe stubs for it.  I want to
> create a haxe program that uses this library and run it under neko.
> Will that work?  Or can I only target the flash platform using this
> approach?
>
> Chris
>
> --
> haXe - an open source web programming language
> http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: as3 in haxe

Chris Ochs
Thanks much for the info guys.

In my case the codebase changes a lot, so porting has to be fairly
automated.  Doesn't look too difficult,  although I could see writing
yet another parser to handle stuff that the current parsers don't.

Chris

On Mon, Jun 20, 2011 at 2:54 AM, [hidden email]
<[hidden email]> wrote:

> No you need to port the code, you can use tools they are links on the wiki
> to partially do it, but here's some tips for doing it by hand.
>
> For most stuff as3 to haXe is quite easy.  You can do a lot with search and
> replace.
> public class to class
> Number to Float
> Boolean to Bool
> int and uint to Int
>
> get space to get_
> set space to set_
> then add in a var ( get_, set_ ): returnType
> then add a return value to the set_ function
> if the gets and sets don't do anything seriously consider just making the
> property public and not using getters and setters, also maybe move to using
> get functions rather than getters.
>
> then you can shift negative tab in and remove the main brackets.
> probably the biggest pain is the array access can't be abused on everything
> in haXe, so you sometimes have to start putting in set's and get's for stuff
> like dictionary access.  And you have to get stricter on basic type
> structures, so
>
> Array's need to be typed
> Array<Float>
>
> functions are often
> Void -> Void
> or maybe
> Event -> Void
>
> although most void's in as3 can just be removed from the end of methods.
>
> from methods you can remove much of the typing of local variables, it cleans
> up the code a lot for reading.
>
> static const  normally becomes inline static var
>
> initialising instance variables needs to be done in the constructor and
> can't be done when declared, but that is normally fairly simple copy the
> offending and some deleting.
>
> for loops can be replaced fairly easily
> for( var i: Int = 0; i < len; i++ )     goes to    for( i in 0...len )
>
> remove breaks from switch statements
>
> look at 'using' for stuff like EReg
>
> probably have to use Std.int, Std.string etc... more than in flash and
> sometimes case( anInstance ,castType ) or cast( anInstance ) to make sure
> you using proper type, but sometimes that is just for the compiler, but it
> will catch more errors.
>
> I am not sure how extensive nme really is for neko so you may need to
> rewrite loading aspects and maybe start with trying to get haXe flash
> working and then 'remap' flash to 'nme'
>
> In terms of tools best off on windows 32bit running flashdevelop, other
> setups work but if you have a choice then this is probably best, unless you
> love textmate like I do :)
>
> in haXe you can have a private constructor which is good if your using a
> singleton.
>
> I think you can swap tweenmax for acurate( ? spelling ) or with more work
> feffect, you can swap signals for hsl or hxs.
>
> you can't use   ||=  or &= .
>
> for optional  parameters to functions you need to add "?"
>
> Hope that helps get you started on hand porting, really it is not hard
> unless you have been too clever.
>
>
> Cheers
>
> ;j
>
>
> On 20 Jun 2011, at 08:38, Chris Ochs wrote:
>
>> Before I go down this path I want to make sure this will (in theory at
>> least) work.
>>
>> I took a sizable as3 library and created haxe stubs for it.  I want to
>> create a haxe program that uses this library and run it under neko.
>> Will that work?  Or can I only target the flash platform using this
>> approach?
>>
>> Chris
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: as3 in haxe

Tony Polinelli
Once it is ported to haxe, you might want to make your changes to the haxe version (not keep re-porting it). You could use the -as3 output (generates as3 code) to port it back to as3 if you need to compile using the flex compiler. Or export to a swc (probably better). Once it is in haxe code, you have many more options. 



On Tue, Jun 21, 2011 at 3:09 AM, Chris Ochs <[hidden email]> wrote:
Thanks much for the info guys.

In my case the codebase changes a lot, so porting has to be fairly
automated.  Doesn't look too difficult,  although I could see writing
yet another parser to handle stuff that the current parsers don't.

Chris

On Mon, Jun 20, 2011 at 2:54 AM, [hidden email]
<[hidden email]> wrote:
> No you need to port the code, you can use tools they are links on the wiki
> to partially do it, but here's some tips for doing it by hand.
>
> For most stuff as3 to haXe is quite easy.  You can do a lot with search and
> replace.
> public class to class
> Number to Float
> Boolean to Bool
> int and uint to Int
>
> get space to get_
> set space to set_
> then add in a var ( get_, set_ ): returnType
> then add a return value to the set_ function
> if the gets and sets don't do anything seriously consider just making the
> property public and not using getters and setters, also maybe move to using
> get functions rather than getters.
>
> then you can shift negative tab in and remove the main brackets.
> probably the biggest pain is the array access can't be abused on everything
> in haXe, so you sometimes have to start putting in set's and get's for stuff
> like dictionary access.  And you have to get stricter on basic type
> structures, so
>
> Array's need to be typed
> Array<Float>
>
> functions are often
> Void -> Void
> or maybe
> Event -> Void
>
> although most void's in as3 can just be removed from the end of methods.
>
> from methods you can remove much of the typing of local variables, it cleans
> up the code a lot for reading.
>
> static const  normally becomes inline static var
>
> initialising instance variables needs to be done in the constructor and
> can't be done when declared, but that is normally fairly simple copy the
> offending and some deleting.
>
> for loops can be replaced fairly easily
> for( var i: Int = 0; i < len; i++ )     goes to    for( i in 0...len )
>
> remove breaks from switch statements
>
> look at 'using' for stuff like EReg
>
> probably have to use Std.int, Std.string etc... more than in flash and
> sometimes case( anInstance ,castType ) or cast( anInstance ) to make sure
> you using proper type, but sometimes that is just for the compiler, but it
> will catch more errors.
>
> I am not sure how extensive nme really is for neko so you may need to
> rewrite loading aspects and maybe start with trying to get haXe flash
> working and then 'remap' flash to 'nme'
>
> In terms of tools best off on windows 32bit running flashdevelop, other
> setups work but if you have a choice then this is probably best, unless you
> love textmate like I do :)
>
> in haXe you can have a private constructor which is good if your using a
> singleton.
>
> I think you can swap tweenmax for acurate( ? spelling ) or with more work
> feffect, you can swap signals for hsl or hxs.
>
> you can't use   ||=  or &= .
>
> for optional  parameters to functions you need to add "?"
>
> Hope that helps get you started on hand porting, really it is not hard
> unless you have been too clever.
>
>
> Cheers
>
> ;j
>
>
> On 20 Jun 2011, at 08:38, Chris Ochs wrote:
>
>> Before I go down this path I want to make sure this will (in theory at
>> least) work.
>>
>> I took a sizable as3 library and created haxe stubs for it.  I want to
>> create a haxe program that uses this library and run it under neko.
>> Will that work?  Or can I only target the flash platform using this
>> approach?
>>
>> Chris
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org



--
Tony Polinelli
http://touchmypixel.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: as3 in haxe

Raoul Duke
On Mon, Jun 20, 2011 at 4:27 PM, Tony Polinelli <[hidden email]> wrote:
> Once it is ported to haxe, you might want to make your changes to the haxe
> version (not keep re-porting it). You could use the -as3 output (generates
> as3 code) to port it back to as3 if you need to compile using the flex
> compiler. Or export to a swc (probably better). Once it is in haxe code, you
> have many more options.

+1
as does anybody else who wants to use it should it ever be released
and desirable :)

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: as3 in haxe

Chris Ochs
In reply to this post by Tony Polinelli
On Mon, Jun 20, 2011 at 4:27 PM, Tony Polinelli <[hidden email]> wrote:
> Once it is ported to haxe, you might want to make your changes to the haxe
> version (not keep re-porting it). You could use the -as3 output (generates
> as3 code) to port it back to as3 if you need to compile using the flex
> compiler. Or export to a swc (probably better). Once it is in haxe code, you
> have many more options.
>

Ya that would be the ideal.  That's probably not going to happen on
our current game, as we are fairly close to release and it's too late
to go making big changes.   Which isn't the end of the world, gives me
time to put together a system for the next game and spend more time
learning haxe/neko.  That said, I might just get the itch to put
together some kind of as3 to haxe parser and/or leverage some of the
tools others have posted.  If neko turns out to be that much better
then tamarin, it might be worth finding a solution for the current
game also.

Chris

--
haXe - an open source web programming language
http://haxe.org