「Creating custom item renderers for the Feathers List control(リンク先へ) 」
を参考にしています。
FeathersExampleのソースコード(リンク先へ)
アイテムレンダラクラスでは、ListクラスからdataProviderで設定した配列の情報を
元に1件毎に表示するリストアイテムのレイアウトを行う事ができます。
アイテムレンダラーはapache Flex(旧Adobe Flex)でも採用しています。
BasicItemRenderer.as
override protected function initialize():void { if(!this.itemBG) { this.itemBG = new Quad(1,1,Math.floor(Math.random() * 0xffffff)); this.addChild(this.itemBG); } if(!this.itemLabel) { this.itemLabel = new Label(); this.addChild(this.itemLabel); } }アイテム内のBGとラベルの初期化をします
BasicItemRenderer.as
protected function layout():void { this.itemBG.width = this.actualWidth; this.itemBG.height = this.actualHeight; this.itemLabel.width = this.actualWidth; this.itemLabel.height = this.actualHeight; this.itemLabel.y = (this.actualHeight / 2) - (this.itemLabel.y / 2); }アイテム内のBGとラベルの大きさ、配置を設定します
BasicItemRenderer.as
protected function commitData():void { if(this._data) { this.itemLabel.text = this._data.text.toString(); } else { this.itemLabel.text = ""; } }アイテム内のラベルの表示情報を設定します
0 件のコメント:
コメントを投稿