FlashDevelop/OpenFL: How to set default target to neko - haxe

I am trying to write some cross-language code with Haxe/OpenFL and compile it using FalshDevelop. But I get an error as soon as I use the basic Sys.print function. A minimal example is as follows:
package;
import flash.display.Sprite;
class Graphic extends Sprite {
public function new () {
super ();
}
static function main() { //used in standalone swf project
Sys.print("Hi");
}
}
It turns out that the default compile command of FlashDevelop is something like:
haxelib run openfl build project.xml flash
,which gives an error on Sys.print:
Graphic.hx:xx: characters 2-11 : Accessing this field requires a system platform
(php,neko,cpp,etc.)
My guess is that Sys.print isn't available in the flash target or flash isn't a system platform (strange). I was wondering if there is way to work around this, and configure FlashDevelop so that the compile command is:
haxelib run openfl build project.xml neko
Thanks

There are actually 2 questions.
For the first one, Sys.print is available only on some platforms because it wouldn't make sense in others(what would it do in flash?), what you probably want is trace, which is used to print things for debug purposes.
For the second question there is a drop down menu at the top of flashdevelop if you created a openfl project that looks like this and does exactly that:

Related

Using `syscall.LINUX_REBOOT_CMD_POWER_OFF` when programming on windows for linux

I'm developing code using Golang on windows as it is easier for testing purposes, but the final bin should run on a raspberry pi.
I need to call syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF) which works fine however, I need to comment it out on windows to test the binary and uncomment it when building in on the rpi.
Even if I test the os to determine if the function is called, since it does not seem to exist on windows, go won't build it.
Is there a way to build the code on windows even though this function doesn't exist?
I do not wish to do any code edits on the rpi, and i cannot use the wsl i need to communicate with usb devices and such which is easier when building on the native os
It sounds like you want conditional compilation as described here:
https://blog.ralch.com/articles/golang-conditional-compilation/
You could have two source files in your package that use the _os nomenclature as the name. Both files export a function that does the appropriate behavior.
reboot_linux.go
package main
import "syscall"
func Reboot() {
syscall.Reboot(syscall.LINUX_REBOOT_CMD_POWER_OFF)
}
reboot_windows.go
package main
import "fmt"
func Reboot() {
fmt.Println("A reboot would have occurred")
}
When you do go build it won't compile reboot_linux.go on Windows. Nor will it compile reboot_windows.go on Linux.
Interestingly enough - this is exactly how Go separates out the implementations of the syscall package in its own source code.

"Module openfl.display.Shader does not define type Shader" when trying to do a release for neko or windows [Flash Develop/Haxe]

this is somenthing I was trying to solve for HOURS, but I don't get why this is not working.
First of all, I'm trying to do a release for neko or windows in Flash Develop. My project is a OpenFl one, and the language is Haxe 3.
What I have installed:
actuate: [1.8.6]
flixel-addons: [2.3.0]
flixel: [4.2.1]
hxcpp: [3.4.64]
lime: [2.9.1]
nape: [2.0.20]
openfl: [3.6.1]
And yes; I'm using haxeFlixel.
When I try to do a release in windows or neko, these errors appear:
-E:/HaxeToolkit/haxe/lib/openfl/3,6,1/openfl/_internal/renderer/opengl/utils/SpriteBatch.hx:12: characters 7-28 : Module openfl.display.Shader does not define type Shader
-E:/HaxeToolkit/haxe/lib/openfl/3,6,1/openfl/_internal/renderer/opengl/utils/SpriteBatch.hx:12: characters 7-28 : For function argument 'ax'
-src/skill/SkillLogicProjectil.hx:13: lines 13-54 : Defined in this class
-E:/HaxeToolkit/haxe/lib/openfl/3,6,1/openfl/_internal/renderer/opengl/shaders2/Shader.hx:11: characters 7-28 : Module openfl.display.Shader does not define type Shader
The most funny thing is: I'm not even using Shader in SkillLogicProjectil. That class only creates a sprite that follows a Player and has a var with the sprite that represents the skill.
If I comment this class, the error is in another class, and finally ends in my GameState.
This error doesn't appear when I do a release in html5. In html5 there are no problems with the release, but I canĀ“t make the game load without Flash Develop running the process in http://localhost:2000/. I need to make a release that can be opened with a computer, without using Flash Develop to open it.
What can I do?.
The new version of Flixel supports Haxe 3.4.3 and OpenFL 8, have you given these versions a try?

Turn on compiler optimization for Android Studio debug build via Cmake

I am using Android Studio 3.0 for my NDK based app.
For the C++ code, I use CMake as the external builder.
This works well, I can create debug and release binaries.
However, I would like to turn on compiler optimizations (say -O3) for a part of the C++ code (the physics engine), not just for the release build, but also for the debug build.
So create the bulk of the debug build as is, without optimizing, yet, I want one of the static library targets to be built with the compiler optimization enabled.
How can I go about this?
I have a CMakeLists for a static library target that gets included using add_subdirectory() directive in the top level CMakeLists file.
Note that I point to the top level CMakeLists in my app's build.gradle file like this:
externalNativeBuild {
cmake {
path '../../Android/jni/CMakeLists.txt'
}
}
It turns out that you can use the target_compile_options() macro in your CMakeLists.txt with a config specification like this:
target_compile_options(opende PRIVATE
"$<$<CONFIG:RELEASE>:-O3>"
"$<$<CONFIG:DEBUG>:-O3>"
)
This macro adds to the existing compile options.

FlashDevelop - Adding Classpath in Haxe project: 'Class not found'

I want to simply create a reusable "library" for all my future projects that I'm going to be doing in Haxe. I understand there aren't library projects in Haxe, but rather you would just have a collection of source files somewhere and import them as needed. Right?
I've created a new project using Flambe (a Haxe framework) and opened it in the FlashDevelop IDE. It compiles and runs fine.
Now I want to include my library, so I go into the Project Properties under the "Classpaths" tab and set the relative path to my library. It shows up correctly in the "References", and even has the proper code completion when I type "import ...", yet when I compile it fails on the import line stating: 'Class not found : mlg.Engine'
(mlg being the package, and Engine being the class/type)
Is there anything I'm missing?
I think (i may be wrong) that flashdevelop "references" are just autocompletion and not actually passed to the compiler.
I'm not sure what's the "right" way to do it, but I can tell you what I've done (I made a few helper classes for flambe too :P): I simply created a "fake" haxelib, I created HaxeToolkit/haxe/lib/[name]/git, and in [name] i created a .current file that contains "git".
Then on flashdevelop you have to add it as a library (Project settings -> Compiler options -> Libraries).
Note: there are probably other/better ways to do it.

Program Not Responding after clean compile?

I've had to move my stuff from a failing hard drive, so I've had to set up and reinstall everything again. And I've run into a couple problems.
So I've got two errors here. The first error that I get is when I open flashdevelop to begin working. I get the error of:
Can't Find Haxelib.exe
And of course, I've installed haxe and haxelib and everything else that's needed pre-setup. However, when I run, the flash and html5 targets work fine regardless. I don't know why that error shows up. Any ideas?
My second problem is that I've installed the necessary stuff for the windows runtime. However, when I try to run the exe in or outside of flashdevelop, the program freezes and gives me the:
This program is not responding.
error that you sometimes see when you crash a program. However, I have my neko stuff set up and it compiles fine, it just crashes on start. I have the background set to neko. I have just a sample hello world FlxText object like this:
hello = new FlxText(0, 0, 100, "Hello World!");
#if neko
hello.color = 0xffffff;
#else
hello.color = 0xffffffff;
#end
add(hello);
Any idea what could be causing the start crashes? It also has me wondering if the two aren't related some how.
Thanks in advance!
Using windows 8, haxe, haxeflixel, windows & neko runtimes.
I had this posted on another forum. The not responding error is fixed easily by adding:
<window allow-shaders="false"/>
In the projects xml file. The haxelib error still shows but it may be a non issue.
Things to try:
Make sure you use Haxe 3 and OpenFL (I think there is no sense of using Haxe 2 or NME).
Check if Haxe on PATH is Haxe 3 and check that OpenFL work fine. (Just open "cmd" and type "haxe" there to see version of Haxe available and type "openfl" there to test if it works, also check "haxelib")
Check FlashDevelop Haxe SDK
Trace your haxelibs here(use haxelib list in cmd)
This program is not responding.
This may mean, that you don't have some .dll in bin folder.(Depending on what you use in your project).
Or this may be connected somehow with your GPU drivers. Or it can be anything other. To get more info about that crash, try compiling to neko, and print output here.
Make sure you have latest haxelibs installed (haxelib upgrade and haxelib selfupdate)
To help you I need more info, print FlashDevelop output here.

Resources