参考:http://blog.sina.com.cn/s/blog_6ca2dfa40100m9tc.html
下面是作者测试的代码,可行。
Main.mxml代码如下:
<?xml version="1.0" encoding="utf-8"?>
<code:AsMain xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:code="*">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextArea id="textArea" text="hello world"></s:TextArea>
</code:AsMain>
AsMain.as代码如下:
package
{
import flash.events.Event;
import spark.components.Application;
import spark.components.TextArea;
/**
* ...
* @author hanyeah
*/
public class AsMain extends Application
{
public var textArea:TextArea;
public function AsMain()
{
super();
stage?initStage(null):addEventListener(Event.ADDED_TO_STAGE, initStage);
}
private function initStage(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, initStage);
textArea.text = "success";
}
}
}
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。