11
2015
05

flex实现代码和布局分离

参考:http://blog.sina.com.cn/s/blog_6ca2dfa40100m9tc.html

下面是作者测试的代码,可行。

Main.mxml代码如下:

  1. <?xml version="1.0" encoding="utf-8"?>

  2. <code:AsMain xmlns:fx="http://ns.adobe.com/mxml/2009"

  3.                xmlns:s="library://ns.adobe.com/flex/spark"

  4.                xmlns:mx="library://ns.adobe.com/flex/mx"

  5.   xmlns:code="*">

  6. <fx:Declarations>

  7. <!-- Place non-visual elements (e.g., services, value objects) here -->

  8. </fx:Declarations>

  9. <s:TextArea id="textArea" text="hello world"></s:TextArea>

  10. </code:AsMain>

AsMain.as代码如下:

  1. package  

  2. {

  3. import flash.events.Event;

  4. import spark.components.Application;

  5. import spark.components.TextArea;

  6. /**

  7. * ...

  8. * @author hanyeah

  9. */

  10. public class AsMain extends Application 

  11. {

  12. public var textArea:TextArea;

  13. public function AsMain() 

  14. {

  15. super();

  16. stage?initStage(null):addEventListener(Event.ADDED_TO_STAGE, initStage);

  17. }

  18. private function initStage(e:Event):void 

  19. {

  20. removeEventListener(Event.ADDED_TO_STAGE, initStage);

  21. textArea.text = "success";

  22. }

  23.  }


  24. }



« 上一篇下一篇 »

相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。