Playing with some haXe updates.
I know this isn’t official yet, but I’m just excited about the changes to come in haXe.
The last couple of days Nicolas committed some interesting updates to the SWF linker. This is the first steps to the upcoming SWC input support.
So, I had to give it a go, and since I’m a fan of Keiths minimalcomps library, I thought it would make a perfect example.
The first obstacle though was that the updates included changes in the dependency libraries for haXe, so first I had to update rewrite my Homebrew Formula to use official repositories for the dependencies so it’ll be prepared for further updates in the long run. It took me a while, and the formula still need some cleanup, but it works rather well by now, hurrah!
And the next step was to follow the instructions of Nicolas email to use a SWC library:
We need to use the SVN version of haXe, which fortunately is very easy to do with homebrew:
# brew install haxe --HEADor, if you prefer, the official way:
# wget http://haxe.org/file/install.ml && ocaml install.mlI’m making a little test project:
# mkdir sofaware # cd sofawareGet the SWC you want:
# wget http://minimalcomps.googlecode.com/files/MinimalComps_0_102.swcExtract the SWC (it’s really only a zipped file) and rename it (library.swf is a bit too generic for my tastes):
# unzip MinimalComps_0_102.swc # mv library.swf minimalcomps-0.102.swfCreate our test file,
Comps.hx:# mate Comps.hxPaste in our little “Hello Keith”-example:
class Comps extends flash.display.Sprite { public function new() { super(); new com.bit101.components.PushButton(this,0,0,"Hello Keith!",function(e){ trace( "Hello there!" ); }); } static function main() { flash.Lib.current.stage.align = flash.display.StageAlign.TOP_LEFT; flash.Lib.current.stage.scaleMode = flash.display.StageScaleMode.NO_SCALE; var c = new Comps(); flash.Lib.current.addChild( c ); } }Compile it and see it in all it’s linked library glory!
# haxe -main Comps -swf comps.swf -swf-version 10 -swf-lib minimalcomps-0.102.swf # open comps.swf
Now that was quite easy, right? And I presume that soon it will be even easier as the SWC will be able to be linked directly. But why not enjoy the upcoming fruits of haXe already? Well, one reason might be file size as it currently links everything even if it’s not used or imported which is something that will be fixed when this feature finally arrives.
sitting in a pleasant sofa is fun.
combine for double the fun.