Using flash package in JS

125 views
Skip to first unread message

Andre Lacasse

unread,
Nov 18, 2016, 11:11:37 AM11/18/16
to Haxe
Hi,

I'm converting a library from Flash to Haxe. The library use flash.geom.Point at some place and this class is not available in JS. For keeping all reference without changing code, I create the class flash.geom.Point for javascript and got this error.

--macro:1: character 0 : You cannot access the flash package while targeting js (for flash.geom.Point)

It's there a way to use flash.geom.Point for Flash and a custom class for JS?

Thank you



Andre Lacasse

unread,
Nov 18, 2016, 11:27:11 AM11/18/16
to Haxe
I can extends the flash.geom.Point in flash target and create a implementation for js target. Any better idea?

Alexander Kuzmenko

unread,
Nov 18, 2016, 1:05:20 PM11/18/16
to Haxe
Try adding --macro allowPackage('flash.geom') to compilation

пятница, 18 ноября 2016 г., 19:27:11 UTC+3 пользователь Andre Lacasse написал:

Andre Lacasse

unread,
Nov 18, 2016, 1:54:18 PM11/18/16
to Haxe
I modify my hxml file with your advice and got another error.

-cp src
-dce no
--macro include('nm')
--macro include('migration',true,['migration.Macro'])
--macro migration.Macro.embedLocalizationFiles('locale')
--each


--macro allowPackage('flash')
--macro include('flash')
-js ../js/mathlib.js


--next


-debug
-swf ../swc/mathlib.swc
-swf-version 11


--next
-as3 as3

$ haxe build.hxml
--macro:1: character 0 : Invalid package : flash._std should be <empty>

Justin L Mills

unread,
Nov 18, 2016, 4:10:04 PM11/18/16
to haxe...@googlegroups.com

I don't understand why you need macros, can you not just use -remap like openfl and nme do when implementing the flash classes.

something like

-remap flash:flashjs

http://old.haxe.org/doc/compiler#compilation-options

You can also do some quite interesting remapping with typedef take a look inside the old library uniflash but you would have to download it from old googlecode so I can't be more specific.

http://lib.haxe.org/legacy/p/uniflash

If I have misunderstood your need sorry on any noise.

Best

Justin
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

David Mouton

unread,
Nov 19, 2016, 2:33:33 AM11/19/16
to Haxe
You can use easeljs, it support all the flash API in Javascript.
just rename flash by easeljs

Andre Lacasse

unread,
Nov 22, 2016, 10:01:08 AM11/22/16
to Haxe
Thank you Justin,

The information is really useful and will solve my problem.
Reply all
Reply to author
Forward
0 new messages