Search code examples
flashdevelop

Embed image issue in FlashDevelop


I'm looking for a solution to embed a image(png) into flashdevelop using the flashpunk library, as I'm pretty new to programming I may not know the most things. Support would be appreciated.

Here is the code:

package 
{

        import net.flashpunk.Entity;
        import net.flashpunk.graphics.Image;


        public class MyEntity extends Entity
        {
                [Embed(source = 'assets/sprite.png')] private const PLAYER:Class;

                public function MyEntity()
                {
                        graphic = new Image(PLAYER);
                }

        }       
}

5: Error: Unable to transcode assets/sprite.png. ^ Build halted with errors (fcsh). (fcsh) Done(1)


Solution

  • If your code is in a folder src in your project, you would need to back out one level before being able to access the image. The code you're looking for is

    [Embed(source = '../assets/sprite.png')] private const PLAYER:Class;