I am trying to figure OpenFL with Haxeflixel out but when I try to run the example project from this tutorial (http://www.openfl.org/learn/tutorials/your-first-project/) 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.
thanks for answering.
I am using the exact code from the example:
package;
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’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. https://www.adobe.com/support/flashplayer/downloads.html
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.
Ahh you are right player_03 After removing static main() it works
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
@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
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.
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 lime.app::Event_Void_Void/dispatch()
at lime.app::Preloader/start()
at openfl.display::Preloader/display_onComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at NMEPreloader/onLoaded()
at openfl.display::Preloader/start()
at lime.app::Preloader/current_onEnter()
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.