Be careful about the "id" property

本文探讨了在InFlex框架中正确使用组件ID的方法。强调了避免将数据ID作为组件ID的重要性,并通过示例展示了如何在List控件中正确获取项目源与ID,确保应用程序的稳定运行。

In Flex, every component is identified by its unique id property. Therefore, in your own data, it's better not to use id as a property.

In the following function, imageList is a List control, the id of each item is not the id of its data provider.

The original data is "<Image source="..." imageId="..."/>"  
  <mx:List width="120" height="100%" id="imageList"
      dataProvider="{images}" itemRenderer="ImageItem"
      change="onChange()" dropShadowEnabled="true" borderStyle="solid" borderThickness="2"></mx:List>
.......
public function onChange():void
{
    //Alert.show(imageList.selectedItem.id.toString());
    imgChara.source=imageList.selectedItem.source;
    imageId=imageList.selectedItem.imageId;
}
The following code does not work correctly!
if the original data is "<Image source="..." id="..."/>"
public function onChange():void
{
    //Alert.show(imageList.selectedItem.id.toString());
    imgChara.source=imageList.selectedItem.source;
    imageId=imageList.selectedItem.id;
}
 
 



                
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值