Search code examples
flashflashdevelophaxe

How to embed and display a png with FlashDevelop, Haxe and Swfmill


I am having trouble getting a png file to display in a simple Flash application I am building using Haxe and FlashDevelop.

Step taken

  • Added the png file to my project.
  • Added the png to the library
  • Set the option to embed as a bitmap
  • Set an Id for the object "PlayerBitmap"
  • Verified that the xml generated looks correct

I then try to display the embedded image:

var bitmap:Bitmap;
bitmap = new PlayerBitmap();
bitmap.x = 200;
bitmap.y = 200; 
addChild(bitmap);

The code compiles and generates a swf file but the image is not shown. Any pointers?


Solution

  • I have solved the issue by creating two simple test projects to load an image. The first worked and the second failed. There was one difference between the projects one had a package.

    The working project my Main does not have a package it is compiled like this -main Main

    The failing project is identical except the main is in a package and it compiles like this -main org.alexjeffery.Main

    To get the image to load when my main was in the org.alexjeffery package I set the image name to org.alexjeffery.PlayerBitmap instead of PlayerBitmap.

    I have now written a tutorial on how to embed images using FlashDevelop and Haxe.