0
我實現IList接口像如何在IList Dataprovider中向DataGroup發送有關數據更改的信號?
[Bindable]
public class MemList implements IList
{
public function MemList()
{
}
public function get length():int
{
var size:int = 5000;
return size;
}
public function addItem(item:Object):void
{
}
public function addItemAt(item:Object, index:int):void
{
}
public function getItemAt(index:int, prefetch:int=0):Object
{
var obj:Object = new Object();
obj.value = ByteStr(); // this function return a string
return obj;
}
public function getItemIndex(item:Object):int
{
return 0;
}
public function itemUpdated(item:Object, property:Object=null, oldValue:Object=null, newValue:Object=null):void
{
}
public function removeAll():void
{
}
public function removeItemAt(index:int):Object
{
return null;
}
public function setItemAt(item:Object, index:int):Object
{
return null;
}
public function toArray():Array
{
return null;
}
public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void
{
}
public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void
{
}
public function dispatchEvent(event:Event):Boolean
{
return false;
}
public function hasEventListener(type:String):Boolean
{
return false;
}
public function willTrigger(type:String):Boolean
{
return false;
}
}
,並DATAGROUP提供其對象作爲數據提供者,在MXML文件我這樣做
<fx:Script><![CDATA[
[Bindable]private var list:MemList = new MemList();
protected function onBtnShow(event:MouseEvent):void
{
send(somenumber, MAX_SIZE, onShowResp);//get data from network
}
private function onShowResp(retVal:uint, ba:ByteArray):void
{
//this function called when ba bytearray is filled with data.
}
]]></fx:Script>
<s:Button id="btnShow" label="Show" click="onBtnShow(event)"/>
<s:Scroller verticalScrollPolicy="auto" id="aScroller"
liveScrolling="false">
<s:DataGroup id="dgMemView" width="100%" height="350"
dataProvider="{list}"
clipAndEnableScrolling="true"
itemRenderer="ItemRenderer"
>
<s:layout>
<s:VerticalLayout useVirtualLayout="true"/>
</s:layout>
</s:DataGroup>
</s:Scroller>
public function ByteStr(loc:uint):String
{
//this function can access ba bytearray filled with data. do some processing
on that data and return a string.
return string;
}
我的問題是,當應用程序運行數據組不顯示任何東西因爲在ba(bytearray)中沒有必須填充網絡數據的數據。當我按下顯示按鈕時,它發出一個請求並用數據填充ba(bytearray)。我如何通知Datagroup數據已更改。我正在使用Flash Builder 4.5。謝謝
最初給數據組提供最大可能長度。如果滾動是在數據組中間的某處。如果發送刷新事件,它將滾動到開始位置。我能阻止這種行爲嗎? – 2013-03-15 09:37:16