New to OpenFL and I can't draw an image

Hello all,

I recently installed OpenFL on my machine currently following the tutorial to draw and image onto screen ( I’m up to the bit where I declared the location of the image I want to draw but when I make a test build, a white screen shows but no image.



import openfl.display.Sprite;
import openfl.display.Bitmap;
import openfl.Assets;

class Main extends Sprite{
     public function new(){
        trace(stage.stageWidth + " " + stage.stageHeight);

        var bitmapData = Assets.getBitmapData("Assets/img/Skeleton_Warrior_Sprite.png");
        var bitmap = new Bitmap(bitmapData);
        bitmap.x = (stage.stageWidth - bitmap.width)/2;
        bitmap.y = (stage.stageHeight - bitmap.height)/2;



<?xml version="1.0" encoding="utf-8"?>
    <meta title="Test2" package="com.sample.test2" version="1.0.0" company="Company Name" />
    <app main="Main" path="Export" file="Test2" />
    <source path="Source" />
    <haxelib name="openfl" />
    <assets path="Assets" rename="assets" />

I’m working on Linux (Bunsen Labs, a derivative of Debian) if that makes any difference. I create a project with the command: openfl create project test2

I make a test build like this: openfl test neko

I also changed the directory so that it’s using a lower case “assets/img/Skeleton_Warrior_Sprite.png” but that doesn’t seem to work either. I tried using a different image (OpenFL logo) but that doesn’t work either.

Sorry if this has been asked before, I’m sure I’m going to feel stupid whatever the answer is

You could test with html5 or flash, that should work.
But better for now is to downgrade to Lime 2.9.0 and OpenFL 3.6.1.
Anything newer won’t work with neko (until fixed).

Thanks, compiling to HTML5 worked.

For future reference, do I install a specific version of lime and openfl through haxelib?


haxelib install lime 2.9.0
haxelib install openfl 3.6.1
haxelib set lime 2.9.0
haxelib set lime 3.6.1

Don’t go for lime 2.9.1. That one’s no good either.
Lime 3/OpenFL 4 is really only for testing at the moment. I’ve noticed Bitmap/BitmapData/Graphics/Sound bugs. Probably a lot more coming up :slight_smile:

1 Like

It sounds like OpenFL 4.0.1 is not rendering images on some graphics drivers – it works here! We’ll figure that out soon. In the meantime, an HTML5 or Flash build will work, or openfl test neko --window-hardware=false disables GL acceleration, and should definitely work :slight_smile:

@singmajesty You would think so :slight_smile: But it doesn’t.

Which platform are you running on?

Ubuntu 16. Neko/Linux targets don’t work, even without GL.

Could you please edit this file on your Lime install. Change it to #if (desktop && !mac && !linux or #if false or something like that


That works, if i use hardware is false.

Hardware true still fails?

@singmajesty Yes (aaarrggghh, why do I need 20 chars, if I just want to say yes :frowning: )

Some conversations are just better suited for chat :slight_smile:

I just removed my current install in to install another an older version as mentioned by Milton. Should I reinstall the latest version again and try this fix? You’d have to tell me where to find the file though :S


I would advice using the stable versions though. Especially since you’re new to OpenFL. There is just no documentation for the latest versions at the moment (especially tilesheet/tilemap).
Samples aren’t up to date etc…

OpenFL 4.0.1 and Lime 3.0.1 are the latest stable versions. We fixed the regression here in Linux asset use, and have another minor release coming soon.

Tilemap is documented here:

We plan to write a blog post about it, it’s a beta API, and its getting closer to its final version

We forgot to update the openfl-samples haxelib in the OpenFL 4 release, sorry about that :blush:. It should be up now

The api is no explanation of how to use it.

Also libraries like bitmapFont are now broken, because they expect Tilesheet.

Stick with the old versions.