Please help me in converting a normal Actionscript code to Haxe code


#1

Hi Guys,

I am new to OpenFL and Haxe .I am Phaser Developer . Can you please help in converting this simple touch flash file so that it acts as reference for my project conversions .

https://drive.google.com/open?id=1s5u7smKXGNT3YijA5UGCDZC3gCl6VXKE

It would be very helpful if you help me in converting this File ASAP.

Thanks,
Raghava


#2

People already gave you a lot of information in your previous topic : Conversion of Flash game to Hmtl5

The file that you are trying to convert is pretty small, so if you really are a developer, you should know what has to be done. But, I’m a bit skeptical, after realizing that you can’t read compiler errors : TypeError: cl is not a constructor

Moreover, this is not the place to ask others to work for you, neither “ASAP”.
There is a “Jobs” section that you may check instead.


#3

Well thanks for the reply. I have mentioned that I am phaser developer I hoped that some help would be given from community side. I even apologize cause the deadline is short.
Thanks for the help .I have removed the file access .
Admin can removed this thread :sleepy::sleepy::cry:


#4

Hello!

Please don’t feel bad about asking questions. In the future, using the same thread for similar questions is probably better, that’s all :slight_smile:

I’ll send you a PM


#5

@Sai_Raghava Hello again! Thank you for sharing your file!

I have it up and running here. It was quite simple, but I totally understand that these little differences are not something that would be obvious at first.

I opened your project, and ran a command to test your project (like this one):

openfl test html5

I got these five errors:

Source/Main.hx:43: characters 24-29 : Type not found : as3hx.Compat
Source/Main.hx:44: characters 24-29 : Type not found : as3hx.Compat
Source/Main.hx:46: characters 22-28 : Type not found : Player
Source/Main.hx:66: characters 8-36 : Float should be Int
Source/Main.hx:67: characters 8-36 : Float should be Int

Never fear! Here was the first set:

Type not found : as3hx.Compat

Before

_destinationX = as3hx.Compat.parseInt(stage.stageWidth / 2);
_destinationY = as3hx.Compat.parseInt(stage.stageHeight / 2);

After

_destinationX = Math.round(stage.stageWidth / 2);
_destinationY = Math.round(stage.stageHeight / 2);

I did not include the as3hx haxelib in the project, but personally, I don’t use the as3hx Compat class, anyway. I’ll explain Float and Int in a moment, here’s the last two errors:

Float should be Int

Before

_destinationX = event.stageX;
_destinationY = event.stageY;

After

_destinationX = Std.int(event.stageX);
_destinationY = Std.int(event.stageY);

Float vs Int

You probably know, that Float represents a floating point number (1.0001, 2.2 or 3.0) and Int represents an integer (1, 2 or 3).

Haxe does not allow Float to be converted implicitly to an Int. You have to either decide to keep it as a Float, or to use a method such as Std.int to opt-into potentially losing precision between the types. So in the above cases, event.stageX and event.stageY are Float values.

Although stage.stageWidth and stage.stageHeight are Int values, dividing will cause Haxe to treat the result as a Float, so stage.stageWidth / 2 also is a Float.

The alternative approach here is to change _destinationX and _destinationY to Float values. That is probably easiest, but I wanted to explain this. Last one:

Type not found : Player

You need the generate option to generate Haxe classes for the “Export for ActionScript” class names defined in your SWF. You may also need a -clean build if you have already performed a build using the same SWF file before.

It looks like this in your project:

<library path="Assets/layout.swf" preload="true" generate="true" />

Result

Here’s a little screenshot of the project running:

image

You can use the NPM release of OpenFL as well, if you prefer to use JavaScript, TypeScript or ActionScript :slight_smile:

Have a great day :smile:


Step by Step procedure to convert a flash game to html5
#6

Thanks Singmajesty :smiley:


#7

hello world hello world hello world hello world