Image.hx

Image import module for importing lossless and lossy compressed image files

Summary
Image.hxImage import module for importing lossless and lossy compressed image files
imageImports specified image from an image file as TBitsLossless2 or TBitsJPEG2 swf tag.

image

Imports specified image from an image file as TBitsLossless2 or TBitsJPEG2 swf tag.

The import method (lossless or lossy) depends on the file type and is determinded automatically.  Any image format supported by ImageMagick (http://www.imagemagick.org/script/formats.php) or DevIL (http://openil.sourceforge.net/features.php) - depending on your configuration - can be used.

Mandatory attributes

importPath to the file to be imported.
classClass name assigned to imported data.

Optional attributes

genclass(false, symbolOnly, symbolAndClass) Controls the generation of symbols and AS3 class stubs.  Available values are: false (don’t generate neither symbol nor AS3 class stub), symbolOnly (generate only symbol), symbolAndClass (generate symbol and AS3 class stub)
maskRelevant only for JPEGs ignored for lossless images.  Path to the file containing the alpha mask.  The dimensions of the image file and mask file has to be identical.

Superclass

flash.display.BitmapThe superclass of the AS3 class stub.

Example 1

Assuming that Image import module is assigned to namespace img the following snippet imports flower.png as a lossless image, exports it with symbolclass name resources.Flower and generates a corresponding AS3 class stub (default behavior):

<img:image import="flower.png" class="resources.Flower"/>

Exampe 2

Import a JPEG file with an alpha mask:

<img:image import="background.jpg" mask="vignette.png" class="resources.BgImage"/>

Example 3

Manual creation of class stub.  First import the image file with genclass set to symbolOnly

<img:image import="texture.jpg" class="resources.FloorTexture" genclass="symbolOnly"/>

then define the class stub in haXe:

package resources;

class FloorTexture extends flash.display.Bitmap {
   public function new() {
      super();
   }
}
Close