我正在尝试将一些 xml 嵌入到我的应用程序中,但出现以下错误
Fault] exception, information=TypeError: Error #1090: XML parser failure: element is malformed.
这是我的代码。
package
{
import com.objects.EngineApi;
import com.objects.Rectangles;
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
/**
* ...
* @author Anthony Gordon
*/
public class Main extends Sprite
{
[Embed(source = "com/files/level1.xml", mimeType = "application/octet-stream")]
private var theClass:Class;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
var xmlObj:Object = new theClass();
trace(xmlObj);
var xml:XML = new XML(xmlObj) as XML;
}
}
}
xml代码
< STAGE>
< OBJECTS>
< BLOCK X="2" Y="23" WIDTH="36" HEIGHT="4" />
< SPAWN X="6" Y="22" />
< BLOCK X="12" Y="21" WIDTH="4" HEIGHT="2" />
< TUTORIAL X="18" Y="16" TEXT="..." />
< TUTORIAL X="28" Y="22" TEXT="..." />
< BLOCK X="36" Y="2" WIDTH="2" HEIGHT="16" />
< JUMPTHRU X="32" Y="9" WIDTH="4" />
< BLOCK X="27" Y="9" WIDTH="5" HEIGHT="2" />
< COIN X="28" Y="7" />
< COIN X="30" Y="7" />
< COIN X="32" Y="7" />
< COIN X="34" Y="7" />
< BLOCK X="17" Y="8" WIDTH="5" HEIGHT="2" />
< BLOCK X="2" Y="9" WIDTH="10" HEIGHT="2" />
< CHEST X="19" Y="7" COINS="5" />
< DOOR X="5" Y="8" />
< BLOCK X="37" Y="20" WIDTH="2" HEIGHT="3" />
< BLOCK X="1" Y="5" WIDTH="3" HEIGHT="4" />
< BIRD_GOLD X="2" Y="4" COINS="3" TIME="5" />
</ OBJECTS>
</ STAGE>