OpenFL Tutorial problem

I am trying to figure OpenFL with Haxeflixel out but when I try to run the example project from this tutorial ( it doesn’t show the image. I have put my image in the assets folder, it compiles but when it runs, it just shows an empty screen. Can someone please help me.


It’s hard to say why would it not work. Can you post your code? What target are you compiling to?

Hi hcwdikk,

thanks for answering.
I am using the exact code from the example:


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

class Main extends Sprite {

    public function new () {

        super ();

        var bitmapData = Assets.getBitmapData ("assets/openfl.png");
        var bitmap = new Bitmap (bitmapData);
        addChild (bitmap);

        bitmap.x = (stage.stageWidth - bitmap.width) / 2;
        bitmap.y = (stage.stageHeight - bitmap.height) / 2;



I compiled it to html5.

I don’t know why but when I try to compile it to flash I get the following error:
This file does not hava a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel.
(I have flash player installed)

When I try to compile to windows I get the following error in the output:
Error: Could not guess MINGW_ROOT (tried [c:/MinGW]) - please set explicitly
Build halted with errors.

I think that on Windows you have o download

Associate .swf with this program so whenever you try to run your flash games it will handle it for you.

For windows, follow this:

I’d recommend this link for the flash player over the one above as it is more up to date and has the latest features. You will need the flash projector content debugger which is the 3rd link.

I don’t think that you can access stage in the constructor. Can you try something like this?

public function new () 
     super ();
     this.addEventListener(Event.ADDED_TO_STAGE, init);
private function init(e:Event):Void
     this.removeEventListener(Event.ADDED_TO_STAGE, init);
     var bitmapData = Assets.getBitmapData ("assets/openfl.png");
     var bitmap = new Bitmap (bitmapData);
     addChild (bitmap);
     bitmap.x = (stage.stageWidth - bitmap.width) / 2;
     bitmap.y = (stage.stageHeight - bitmap.height) / 2;

You can access stage from the Main class, you have been able to since OpenFL 1.0 I believe :slight_smile:

You mean by using Lib.current.stage? Because otherwise, you have to wait for an ADDED_TO_STAGE event. (And yes, I double-checked.)

No, I mean by stage directly from the Main class of your project. Obviously (like Flash) you need to wait until an object has been added to the stage outside of the Main class.

The “DisplayingABitmap” sample (and others) use stage from the Main class, and not Lib.current.stage, and work everywhere I test them.

Ah, I see the problem. In my test project, I still had a static main() function, which meant it skipped the DocumentClass constructor, which is what adds it to the stage.

It throws an error when I’m trying to access the stage from the constructor.

Ahh you are right player_03 :slight_smile: After removing static main() it works :slight_smile:
Anyway since the default flashdevelop template creates static function main I can see why would this example not work for some people.

Ah, yeah, that’s true – it favors a static main if you use one. If you do, that means that you’re in charge of instantiating and adding things to the stage

I am mad now because you lie me about common error message like my same problem. I know now

It sees same error message. I know now

@hcwdikk is good hero how do you force again bad helpers because I have same error message.
Check my thread scroll to post #6 because other helpers don’t know about error message. I always tried that is why.
Thanks you’re hero!!! PS: I am mad to @player_03 because he doesn’t know my error message

Thanks now!

These are not the same error message. The error in this thread was a null reference exception, and the errors in the other thread had to do with overriding a class.

Post your code and your error if you want help with it. Don’t just copy hcwdikk’s screenshot, because that isn’t your code or your error.


my god you don’t read correct same error message

VerifyError: Error #1053: Illegal override of Component in net.sourceskyboxer.components.Component.
	at Main()
	at DocumentClass()
	at Type$/createInstance()
	at ApplicationMain$/start()
	at ApplicationMain$/init()
	at openfl.display::Preloader/display_onComplete()
	at NMEPreloader/onLoaded()
	at openfl.display::Preloader/start()

It means NMEPreloader and ApplicationMain.hx errors

But you have fixed ApplicationMain.hx from Github I have copied to my original installed OpenFL 3.6.0/templates/haxe

But I can not understand that is why it happens If i create Component.hx than it got error becasue I didn’t check ApplicationMain.hx That is why my original installed template of haxe was got wrong version because it used 3.6.0 And I try to copy manuell and it works fine.

That is why I prove you.

According to this, that error can occur when your class doesn’t match an interface.

Does the Component class implement an interface? If so, does this interface use the same @:getter and @:setter tags as the Component class?