MXML文件如何引用文档类?
我建了一个文档类如下:
- JScript code
package begin{ import flash.text.*; import flash.display.Sprite; [swf(width="400",height="200",frameRate="25",backgroundColor="#ffffff")] public class begintest extends Sprite { public function begintest() { var mytext:TextField=new TextField(); mytext.autoSize=TextFieldAutoSize.LEFT; mytext.text="这是一个测试"; var myformat:TextFormat=new TextFormat(); myformat.size=55; myformat.color=0x336699; mytext.setTextFormat(myformat); addChild(mytext); } }}
我建了一个MXML文件,想在其中中引用,我的代码如下:
- XML code
<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="addtest()"><mx:Script> <![CDATA[ import begin.begintest; protected function addtest():void{ var begin:begintest=new begintest(); } ]]></mx:Script></mx:Application>
结果什么也不显示,刚学,请问一下各位高手,我的是哪里错了呢?
[解决办法]
var begin:begintest=new begintest();
this.addChild(begin);
要将begin加入到主场景中