list标签里的值怎样取出

myeclipse0123 2010-11-23 08:52:36
该程序是flex解析xml而得到的解析

sample.xml文件

<devices>
<item location="" model="2010" device_id="d.test.0011" type="pc" memo="" owner_id="18900013399"/>
<item location="" model="2010" device_id="d.test.shennun1" type="pc" memo="" owner_id="18900013399"/>
<item location="" model="tv2010" device_id="d.test.devie_001" type="tv" memo="" owner_id="18900013399"/>
<item location="" model="igrs" device_id="d.test.fanjx1" type="stb" memo="" owner_id="18900013399"/>
<item location="" model="" device_id="d.test.fanjx3" type="pc" memo="" owner_id="18900013399"/>
<item location="" model="pc" device_id="d.test.pc.fanjx1" type="pc" memo="" owner_id="18900013399"/>
<item location="" model="pc" device_id="d.test.pc.fanjx3" type="pc" memo="" owner_id="18900013399"/>
<item location="" model="SS200-GW" device_id="d.test.ss200-gw.fanjx1" type="stb" memo="" owner_id="18900013399"/>
<item location="" model="stb" device_id="d.test.stb.fanjx1" type="stb" memo="" owner_id="18900013399"/>
<item location="" model="tv" device_id="d.test.tv.fanjx1" type="pc" memo="" owner_id="18900013399"/>
<item location="" model="zteiptv" device_id="d.test.zteiptv.shennun1" type="stb" memo="" owner_id="18900013399"/>
<item location="" model="magictouch" device_id="dd8adec4de14d3f01d21a7ebaf2fb82a" type="magictouch" memo="memo_test" owner_id="test2017"/>
</devices>




mxml: 文件


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="init()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.controls.listClasses.ListBaseContentHolder;

private function init():void{
rightClick();
}
//右键的操作
[Bindable]
public var cm:ContextMenu = null;
private function rightClick():void{
cm = new ContextMenu();
var xz:ContextMenuItem = new ContextMenuItem("右键复制",true);
cm.hideBuiltInItems(); // 隐藏一些内建的鼠标右键菜单项
xz.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,onset);
cm.customItems.push(xz);
cm.addEventListener(ContextMenuEvent.MENU_SELECT,onselect);
//this.contextMenu = cc;
}
public function onset(evt:ContextMenuEvent):void{
Alert.show((deviceList.getChildAt(0) as ListBaseContentHolder).toString());//在这里怎样取到linkbutton的Label值
}
private var rightSelect:Number;
public function onselect(event:ContextMenuEvent):void{
deviceList.selectedIndex = rightSelect;
}
]]>
</mx:Script>
<mx:Model id="res" source="states.xml"/>
<mx:Canvas id="main" width="100%" height="100%" backgroundAlpha="#ffffff">
<mx:List height="400" left="233.5" right="433.5" bottom="69" id="deviceList"
contextMenu="{cm}" itemRollOver="rightSelect = event.rowIndex">
<mx:itemRenderer>
<mx:Component>
<mx:Canvas>
<mx:Image styleName="tempSource" source="assets/images/pc.jpg" />
<mx:LinkButton x="35" height="35" label="{data.device_id}" />
</mx:Canvas>
</mx:Component>
</mx:itemRenderer>
</mx:List>
</mx:Canvas>
</mx:Application>


看着挺长,其实直接拷贝就可以用了
...全文
173 8 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
leemiki 2010-11-24
  • 打赏
  • 举报
回复
上面的代码思路完全正确,取值上有点问题,^_^

public function onset(evt:ContextMenuEvent):void{
Alert.show(deviceList.selectedItem.device_id);
}

就这么简单~~~

myeclipse0123 2010-11-24
  • 打赏
  • 举报
回复
xiexie 4楼和7楼
passself 2010-11-24
  • 打赏
  • 举报
回复
4楼的可以,也可以这样res.item[rightSelect].device_id,被选中的
fw176170847 2010-11-24
  • 打赏
  • 举报
回复
...,非关键时刻,你也能蹦出来
  • 打赏
  • 举报
回复
沧桑,有人说你可爱...
leemiki 2010-11-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 fw176170847 的回复:]
这问题太有爱了
[/Quote]
。。。。。

楼上你也挺可爱,O(∩_∩)O~
fw176170847 2010-11-23
  • 打赏
  • 举报
回复
这问题太有爱了

4,327

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计 Flex
社区管理员
  • Flex
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧