Skip to content

Instantly share code, notes, and snippets.

@Hasufel
Created November 5, 2013 18:42
Show Gist options
  • Save Hasufel/7323899 to your computer and use it in GitHub Desktop.
Save Hasufel/7323899 to your computer and use it in GitHub Desktop.
Simple Xml Loading using OpenFL - crashes on MAC OS X 10.6 with error: [0x0-0x24024].com.my.application[199] Terminal error type not string, File .//libs/std/Xml.cpp, line 386. Does not crash on Mac OS X 10.8. Architecture: - src/LoadingXml.hx - assets/english.xml - project.nmml
<?xml version="1.0" encoding="UTF-8"?>
<Language Name="english">
<Term Name="welcomeuser">welcome.</Term>
</Language>
package;
import nme.Assets;
import nme.display.Sprite;
import nme.Lib;
import sys.io.File;
import sys.FileSystem;
class LoadingXml extends Sprite {
public function new() {
super();
haxe.Timer.delay(init,500);
}
private function init():Void {
loadXml("assets/english.xml", computeXml);
}
private function loadXml(s:String,func:String -> Void):Void {
func(Assets.getText(s));
}
private function computeXml(xml:String):Void {
var x = new haxe.xml.Fast(Xml.parse(xml).firstElement());
}
static public function main() {
var stage = Lib.current.stage;
Lib.current.addChild(new LoadingXml());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project>
<meta title="LoadingXml" package="org.openfl.loadingxml" version="1.0.0" company="OpenFL" description="Loading Xml"/>
<app main="LoadingXml" file="LoadingXml" path="bin" />
<window background="#000000" />
<window orientation="landscape" />
<window width="1280" height="720" fullscreen="false" resizable="true" antialiasing="0" hardware="true" if="mac"/>
<window fps="60" if="desktop" />
<source path="src" />
<haxelib name="nme" />
<assets path="assets" />
<ndll name="std" />
<ndll name="regexp" />
<ndll name="zlib" />
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment