#2

time - 6:34

Adding images to your HaXe project using SWFMILL

In this episode I will show you how to setup your development environment on OS X so you can use swfmill to compile image resources for you HaXe projects, if you are running windows it should work as well

download: mp4    ogv  m4v  source code

Before proceeding check if swfmill is installed

$ swfmill -v

HaxeCastsBitmap.hx

import flash.display.Bitmap; class HaxeCastsBitmap extends Bitmap { public function new() { super(); } }
Main.hx

package; import flash.display.Sprite; import flash.Lib; import flash.display.LoaderInfo; class Main extends Sprite { static function main() { new Main(); } public function new() { super(); Lib.current.addChild(new HaxeCastsBitmap()); } }

You can embed images, fonts, audio and other swf files with swfmill here we are looking at embedding an image file.
When the xml file is ready you have to compile it from the terminal:

$ swfmill simple resource.xml resource.swf

resource.xml

<?xml version="1.0" encoding="iso-8859-1" ?> <movie version="9" width="800" height="261" framerate="30"> <frame> <library> <bitmap id="HaxeCastsBitmap" import="library/images/haxe_casts.png" /> </library> </frame> </movie>

To use the resource.swf file we just compiled we have to the build.hxm file to include the resource.swf file

build.hxml

-cp src -cp src/interfaces -cp src/bitmaps -main Main -swf-lib ../swfmill/resource.swf -swf9 bin/episode-002.swf -swf-header 423:56:20:eeeeee -swf-version 10 -debug

Demo

episode-002.swf

output

Alternative content

Get_flash_player