본문 바로가기

AS

TileListData 의 활용법..

먼저 생성자는

TileListData () Constructor
public function TileListData(label:String, icon:Object, source:Object, owner:UIComponent, index:uint, row:uint, col:uint = 0)
Language Version : ActionScript 3.0
Player Version : Flash Player 9.0.28.0

Creates a new instance of the TileListData class as specified by its parameters. The TileListData class inherits the properties of the ListData class, and adds a source parameter for the path to the image that is associated with the cell.

Parameters
label:String — The label to be displayed in this cell.
 
icon:Object — The icon to be displayed in this cell.
 
source:Object — The path or class that is associated with the content to be displayed in the cell.
 
owner:UIComponent — The component that owns this cell.
 
index:uint — The index of the item in the data provider.
 
row:uint — The row in which this item is being displayed. In a List or DataGrid, this corresponds to the index. In a TileList it may be different than the index.
 
col:uint (default = 0) — The column in which this item is being displayed. In a List this will always be equal to 0.

이렇고.. 여기서 중요한 건 source 부분인데 이 source 는 아래와 같은 특징이 있다.

source property
source:Object  [read-only]

Gets or sets an absolute or relative URL that identifies the location of the SWF or image file to load, the class name of a movie clip in the library, or a reference to a display object. The TileListData does not load the source, it only passes the value of the source on to the ImageCell.

Valid image file formats include GIF, PNG, and JPEG.

The default value is null.

그래서 다음과 같은 소스코드를 작성할 수 있다.

1. 클래스 이름으로 처리하기 ( getRandomImageCellSource() 함수는 클래스 이름을 리턴)
dp.addItem( { label:"Item " + i, source:getRandomImageCellSource() } );

2. 이미지 URL 을 넘겨주기
dp.addItem( { label:"Item " + i, source:"http://Image-URL",  } );

3. Display 객체를 넘겨주기 ( getSpriteCellSource() 함수는 Spirte 객체를 만들어 리턴)
dp.addItem( { label:"Item " + i, source:getSpriteCellSource(),  } );