博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
flex addChild 的一个小细节
阅读量:4079 次
发布时间:2019-05-25

本文共 920 字,大约阅读时间需要 3 分钟。

关键字: flex, addchild

 

如果addChild的参数是别的容器的child, 那么这个child就会被"移动"(即先从就容器中removeChild掉,然后在addChild到新容器中,没必要自己去removeChild)到新的容器里

 

 

Java代码
  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"  
  3.     width="800"  
  4.     height="600"  
  5.     creationComplete="init()">   
  6.     <mx:Script>   
  7.         <![CDATA[   
  8.             import mx.controls.Label;   
  9.             private var lab:Label = new Label();   
  10.             private function init():void  
  11.             {   
  12.                 lab.text = "I am a label";   
  13.                 c1.addChild(lab);   
  14.             }   
  15.                
  16.             private function onClick(event:MouseEvent):void  
  17.             {   
  18.                 if(event.currentTarget == c1 &&lab.parent != c1)   
  19.                 {   
  20.                     c1.addChild(lab);   
  21.                 }   
  22.                 if(event.currentTarget == c2 &&lab.parent != c2)   
  23.                 {   
  24.                     c2.addChild(lab);   
  25.                 }   
  26.             }   
  27.         ]]>   
  28.     </mx:Script>   
  29.     <mx:Canvas id="c1" width="50%" height="100%" backgroundColor="blue" click="onClick(event)"/>   
  30.     <mx:Canvas id="c2" width="50%" height="100%" backgroundColor="red" click="onClick(event)"/>   
  31. </mx:Application> 

posted on 2010-06-18 09:19 阅读(...) 评论(...)

转载地址:http://oepni.baihongyu.com/

你可能感兴趣的文章
UIView的使用setNeedsDisplay
查看>>
归档与解归档
查看>>
Window
查看>>
为什么button在设置标题时要用一个方法,而不像lable一样直接用一个属性
查看>>
字符串的截取
查看>>
2. Add Two Numbers
查看>>
17. Letter Combinations of a Phone Number (DFS, String)
查看>>
93. Restore IP Addresses (DFS, String)
查看>>
19. Remove Nth Node From End of List (双指针)
查看>>
49. Group Anagrams (String, Map)
查看>>
139. Word Break (DP)
查看>>
Tensorflow入门资料
查看>>
剑指_用两个栈实现队列
查看>>
剑指_顺时针打印矩阵
查看>>
剑指_栈的压入弹出序列
查看>>
剑指_复杂链表的复制
查看>>
服务器普通用户(非管理员账户)在自己目录下安装TensorFlow
查看>>
星环后台研发实习面经
查看>>
大数相乘不能用自带大数类型
查看>>
字节跳动后端开发一面
查看>>