0
我試圖單純地在動作腳本中編寫項目渲染器(在Flash Builder 4.6中),因爲與內置渲染器相比,動作腳本似乎提供了更快且更可定製的接口。 (標籤/圖標等)。在Flash Builder中的ActionScript中編寫ItemRenderer
我希望列表顯示圖像和兩個文本字段。目前它將所有這些元素放置在畫布上,但只要我開始滾動(並且虛擬列表有效),我的舊元素不會從舞臺上移除。例如: 之前滾動 http://i.stack.imgur.com/Mk5HX.png 滾動 http://i.stack.imgur.com/Qt7wZ.png
數據存儲在名稱,形象,公司與標題後。
任何關於這個問題的幫助,或者事實上更好的方法來做我想做的事情將不勝感激。
目前,我有一個類(我已經刪除了進口等)
public class UILabel2 extends IconItemRenderer
{
public function UILabel2() {
super();
}
override public function set data(value:Object):void
{
super.data = value;
var DBname:String = data.name as String;
var DBimage:String = data.image as String;
var DBcompany:String = data.Company as String;
var DBtitle:String = data.Title as String;
//iconField = location;
trace(DBname);
label = DBname;
messageField = "Peanuts";
//iconWidth=64;
//iconHeight=64;
avatarHolder = new Graphic();
avatar = new BitmapImage();
iconField = DBimage;
avatar.fillMode = "clip";
avatar.source = DBimage;
avatarHolder.width = 64;
avatarHolder.height = 64;
avatarHolder.addElement(avatar);
addChild(avatarHolder);
text2 = new TextField();
text2.x = textMargin;
text2.y = 45;
text2.text = DBcompany;
addChild(text2);
var text3:TextField = new TextField();
text3.x = textMargin;
text3.y = 25;
text3.text = DBtitle;
addChild(text3);
//trace(listArrow1MED);
arrowHolder = new Graphic();
//arrowHolder.width = 20;
//arrowHolder.height = 20;
arrowHolder.x= Wsize-40;
//trace(Wsize);
arrow = new BitmapImage();
arrow.fillMode = "clip";
arrow.source = listArrow1LGE;
arrowHolder.addElement(arrow);
addChild(arrowHolder);
//iconField = avatar;
}
你一直是最好的幫助,謝謝你的簡潔明瞭的答案!修正它吧。 – user1383938
我只是偶然發現了這個問題,並會評論你的答案。雖然通常是正確的,但不應將元素的創建移到構造函數中。正確的位置是'createChildren'方法。 – AlBirdie