<![CDATA[ function():void; ]]>
Код AS3:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var urlLoader:URLLoader = new URLLoader(new URLRequest('init.xml'));
urlLoader.addEventListener(Event.COMPLETE, ON_COMPLETE);
function ON_COMPLETE (e:Event):void
{
var xml:XML = new XML(e.target.data);
var fun:Function = new Function;
fun = xml.script.hello as Function; // null
// fun = xml.script as Function; // null
if (fun != null) fun.call();
}
}
}
}
Код AS3:
<?xml version="1.0" encoding="utf-8" ?>
<data>
<script>
<![CDATA[
function hello ():void
{
trace("Hello world!");
}
]]>
</script>
</data>
Подскажите, что я делаю не так?
|