flex 动态给控件赋值,通过反射遍历MXML中的组件
来源:互联网 发布:域名交易中心 编辑:程序博客网 时间:2024/05/01 09:37
flex 动态给控件赋值,通过反射遍历MXML中的组件。当有100个mx:TextInput 需要给他们text属性赋值的时候,如果id存在规律可以用for,但如果id完全没规律的话那麽就需要用下面方法了,通过反射
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Canvas id="s" width="263" height="193" backgroundImage="../img/infobg.png">
<mx:Canvas id="k" width="243" height="141.1" x="10" y="41.9">
<mx:Script>
<![CDATA[
import mx.controls.TextInput;
import mx.controls.Button;
public function dkdk(){
var instanceInfo:XML=describeType(this);//通过反射机制取出当前MXML中的信息
var properties:XMLList =instanceInfo..accessor.(@type=="mx.controls::TextInput")
trace(instanceInfo..accessor.(@type=="mx.controls::TextInput"));
for each(var propertyInfo:XML in properties){
var propertyName:String =propertyInfo.@name;//此处取出的为textinput的id
TextInput(this[propertyName]).text="1111";
}
}
]]>
</mx:Script>
<mx:TextInput id="a" x="0" y="1" width="90" height="17.6"/>
<mx:TextInput id="b" x="89.05" y="1" width="117.899994" height="17.6"/>
<mx:TextInput x="0" y="20" width="90" height="17.6"/>
<mx:TextInput x="89.05" y="20" width="117.899994" height="17.6"/>
<mx:TextInput x="0" y="39" width="90" height="17.6"/>
<mx:TextInput x="89.05" y="38" width="117.899994" height="17.6"/>
<mx:TextInput x="0" y="58" width="90" height="17.6"/>
<mx:TextInput x="89.05" y="58" width="117.899994" height="17.6"/>
<mx:TextInput x="0" y="77" width="90" height="17.6"/>
<mx:TextInput x="89.05" y="77" width="117.899994" height="17.6"/>
<mx:TextInput x="0" y="96" width="90" height="17.6"/>
<mx:TextInput x="89.05" y="96" width="117.899994" height="17.6"/>
<mx:TextInput id="p" x="0" y="115" width="90" height="17.6"/>
<mx:TextInput x="89.05" y="115" width="117.899994" height="17.6"/>
</mx:Canvas>
</mx:Canvas>
<mx:Button x="332" y="107" label="Button" click="dkdk()"/>
</mx:Application>
- flex 动态给控件赋值,通过反射遍历MXML中的组件
- 通过反射给bean赋值
- 动态给已知ID的控件中的控件赋值
- Flex as类文件调用mxml中的控件或方法
- 通过反射技术创建窗体实例然后给控件赋值(C#)
- 通过属性名利用反射给控件赋值或者取值
- java反射机制动态给属性赋值
- 通过反射将数组中的元素给一个对象中的各个字段赋值
- 动态添加控件,给控件赋值
- mxml中动态生成组件
- Flex反射:通过调用getDefintionByName函数动态创建按钮等控件的例子
- flex自定义组件(mxml文件)
- flex自定义组件(mxml文件)
- Flex String类型的日期时间给日期组件赋值
- 代码 - 通过反射对象属性进行遍历赋值
- VS2008 WinForm中通过反射遍历程序中的窗体及窗体上的控件
- c# 利用反射动态给实体类对象赋值
- c# 利用反射动态给实体类对象赋值
- 如何静态链接pthreads-win32
- 中文参考手册---6MySQL存取权限系统
- 很全面的,很好的一片论文,主要是在线考试
- 建立自己的WAP手机网站
- 中文参考手册5MySQL与标准的兼容性?
- flex 动态给控件赋值,通过反射遍历MXML中的组件
- 我的愿望---写在三十岁之前
- 中文参考手册3(MySQL许可证和技术支持)
- 读书笔记《道法自然--面向对象实践指南》第二章
- 昨天晚上失眠了
- UMLCHINA 首席专家潘加宇鼎力推荐
- 中文参考手册2(MySQL邮件列表及如何提问或报告错误)
- .NET中一般处理程序(ashx)在Ajax中的使用--下拉列表的动态级连
- 步入正轨