首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

小弟我想用一个通用的填充数组的函数来给Combobox赋值,为什么就不行了

2012-03-12 
我想用一个通用的填充数组的函数来给Combobox赋值,为什么就不行了我想用一个通用的填充数组的函数来给Comb

我想用一个通用的填充数组的函数来给Combobox赋值,为什么就不行了
我想用一个通用的填充数组的函数来给Combobox赋值,为什么就不行了.
通过调试得知,在fillArray里能拿到数组,但是aryPrev拿不到
在页面加载后填充数据

utils.Tools.fillArray(aryPrev, "Opt_AdEffect", null);

//填充一个数组
public static function fillArray(ary :ArrayCollection, tabname:String, selectedValue:Object):void{
var ro:RemoteObject = new RemoteObject("GenericDestination");
var _result:Function = function(e:ResultEvent):void 
{
ro.removeEventListener(ResultEvent.RESULT, _result);
ro.removeEventListener(FaultEvent.FAULT, _fault);
ary = new ArrayCollection(e.result as Array);
 
}
var _fault:Function = function(e:FaultEvent):void 
{
ro.removeEventListener(ResultEvent.RESULT, _result);
ro.removeEventListener(FaultEvent.FAULT, _fault);
}
 
ro.source = "CRM.BLL.Opt_Table";
ro.addEventListener(ResultEvent.RESULT, _result);
ro.addEventListener(FaultEvent.FAULT, _fault);
ro.GetList(tabname);
}

//在Grid里显示下拉框,获取焦点时刷新数组
<mx:DataGrid height="100%" width="100%" id="dg" dataProvider="{ary}">
<mx:columns>
<mx:DataGridColumn headerText="过往媒体" dataField="Code">
<mx:itemRenderer>
<mx:Component>
<mx:ComboBox width="100%" labelField="Name" dataProvider="{outerDocument.aryPrev}"
  focusIn="{abc()}">
<mx:Script>
<![CDATA[
private function abc():void{
outerDocument.aryPrev.refresh();
}
]]>
</mx:Script>
</mx:ComboBox>
 
</mx:Component>



[解决办法]
这貌似是一个基础问题
public static function fillArray(ary :ArrayCollection, tabname:String, selectedValue:Object):void{
// 下面这个修改了ary的指向,外部传过来的数据是不会受影响的
ary = new ArrayCollection(e.result as Array);
// 
// var item:Object = {};
 // item[tabname] = selectedValue;
// ary.addItem(item); //这样写外部传过来的数据就被修改了。
}
所以你在外面调用utils.Tools.fillArray(aryPrev, "Opt_AdEffect", null);以后
aryPrev还是原来的样子。

热点排行