ADOBE/ ActionScript

플래시 fl.controls.TileList 관련, 리스트안에 컨트롤

AlrepondTech 2011. 12. 9. 18:23
반응형

 

 

 

 

 

=================================

=================================

=================================

 

 

 

 

 

 

TileList 세로로 스크롤 하기

listTile.direction = ScrollBarDirection.VERTICAL;

 

 

 

=================================

=================================

=================================

 

 




//출처: http://www.arkansasweb.com/fms/docs/flashmediaserver_AS3LR/fl/controls/TileList.html


Property Detail

columnCount property
columnCount:uint  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the number of columns that are at least partially visible in the list. Setting the columnCount property changes the width of the list, but the TileList component does not maintain this value. It is important to set the columnCount value after setting the dataProvider and rowHeight values. The only exception is if the rowCount is set with the Property inspector; in this case, the property is maintained until the component is first drawn.

The default value is 0.


Implementation
    public function get columnCount():uint
    public function set columnCount(value:uint):void

See also


Example

The following example creates a TileList component instance and resizes it by setting its columnCount and rowCount properties:
import fl.controls.TileList; import fl.controls.ScrollBarDirection;  var myTileList:TileList = new TileList(); myTileList.addItem({label:"Image 1", source:"http://www.helpexamples.com/flash/images/image1.jpg"}); myTileList.addItem({label:"Image 2", source:"http://www.helpexamples.com/flash/images/image2.jpg"}); myTileList.addItem({label:"Image 3", source:"http://www.helpexamples.com/flash/images/image3.jpg"}); myTileList.direction = ScrollBarDirection.VERTICAL; myTileList.columnWidth = 200; myTileList.rowHeight = 134; myTileList.columnCount = 1; myTileList.rowCount = 2; myTileList.move(10, 10); addChild(myTileList); 

columnWidth property  
columnWidth:Number  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the width that is applied to a column in the list, in pixels.

The default value is 50.


Implementation
    public function get columnWidth():Number
    public function set columnWidth(value:Number):void

See also


Example

The following example creates a TileList component instance and sets its columnWidth and rowHeight properties based on the value of a slider:
import fl.controls.Slider; import fl.controls.TileList; import fl.data.DataProvider; import fl.events.SliderEvent;  var baseURL:String = "http://www.helpexamples.com/flash/images/";  var imagesXML:XML = <images>         <img src="image1.jpg" alt="Image 1" />         <img src="image2.jpg" alt="Image 2" />         <img src="image3.jpg" alt="Image 3" />     </images>;  var dp:DataProvider = new DataProvider(imagesXML);  var columnWidthSlider:Slider = new Slider(); columnWidthSlider.minimum = 50; columnWidthSlider.maximum = 200; columnWidthSlider.liveDragging = true; columnWidthSlider.snapInterval = 10; columnWidthSlider.tickInterval = 10; columnWidthSlider.width = columnWidthSlider.maximum - columnWidthSlider.minimum; columnWidthSlider.move(10, 10); columnWidthSlider.addEventListener(SliderEvent.CHANGE, changeHandler); addChild(columnWidthSlider);  var myTileList:TileList = new TileList(); myTileList.dataProvider = dp; myTileList.labelField = "alt"; myTileList.sourceFunction = mySourceFunction; myTileList.width = 530; myTileList.rowCount = 1; myTileList.move(10, 30); addChild(myTileList);  function mySourceFunction(item:Object):String {     return baseURL + item.src; }  function changeHandler(event:SliderEvent):void {     myTileList.columnWidth = event.value;     myTileList.rowHeight = event.value;     myTileList.rowCount = 1; } 

dataProvider property  
dataProvider:DataProvider  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the data model of the list of items to be viewed. A data provider can be shared by multiple list-based components. Changes to the data provider are immediately available to all components that use it as a data source.

 


Implementation
    public function get dataProvider():DataProvider
    public function set dataProvider(value:DataProvider):void

Example

The following example creates a new TileList and adds items to its data provider using the addItem() method:
import fl.controls.TileList; import fl.data.DataProvider;  var dp:DataProvider = new DataProvider(); dp.addItem({label:"Image 1", source:"http://www.helpexamples.com/flash/images/image1.jpg"}); dp.addItem({label:"Image 2", source:"http://www.helpexamples.com/flash/images/image2.jpg"}); dp.addItem({label:"Image 3", source:"http://www.helpexamples.com/flash/images/image3.jpg"});  var myTileList:TileList = new TileList(); myTileList.dataProvider = dp; myTileList.columnWidth = 100; myTileList.rowHeight = 100; myTileList.columnCount = 2; myTileList.rowCount = 2; myTileList.move(10, 10); addChild(myTileList); 

The following example creates a new TileList and adds items to its data provider by passing an Array object to the DataProvider constructor:
import fl.controls.TileList; import fl.data.DataProvider;  var itemsArray:Array = new Array(); itemsArray.push({label:"Image 1", source:"http://www.helpexamples.com/flash/images/image1.jpg"}); itemsArray.push({label:"Image 2", source:"http://www.helpexamples.com/flash/images/image2.jpg"}); itemsArray.push({label:"Image 3", source:"http://www.helpexamples.com/flash/images/image3.jpg"});  var dp:DataProvider = new DataProvider(itemsArray);  var myTileList:TileList = new TileList(); myTileList.dataProvider = dp; myTileList.columnWidth = 100; myTileList.rowHeight = 100; myTileList.columnCount = 2; myTileList.rowCount = 2; myTileList.move(10, 10); addChild(myTileList); 

The following example creates a new TileList and adds items to its data provider by passing an XML object to the DataProvider constructor:
import fl.controls.TileList; import fl.data.DataProvider;  var itemsXML:XML = <items>         <item label="Image 1" source="http://www.helpexamples.com/flash/images/image1.jpg" />         <item label="Image 2" source="http://www.helpexamples.com/flash/images/image2.jpg" />         <item label="Image 3" source="http://www.helpexamples.com/flash/images/image3.jpg" />     </items>;  var dp:DataProvider = new DataProvider(itemsXML);  var myTileList:TileList = new TileList(); myTileList.dataProvider = dp; myTileList.columnWidth = 100; myTileList.rowHeight = 100; myTileList.columnCount = 2; myTileList.rowCount = 2; myTileList.move(10, 10); addChild(myTileList); 

direction property  
direction:String  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets a value that indicates whether the TileList component scrolls horizontally or vertically. A value of ScrollBarDirection.HORIZONTAL indicates that the TileList component scrolls horizontally; a value of ScrollBarDirection.VERTICAL indicates that the TileList component scrolls vertically.

The default value is ScrollBarDirection.VERTICAL.


Implementation
    public function get direction():String
    public function set direction(value:String):void

See also


Example

The following example creates a TileList componenent instance and sets its scrolling direction to vertical:
import fl.controls.ScrollBarDirection; import fl.controls.TileList;  var baseURL:String = "http://www.helpexamples.com/flash/images/";  var myTileList:TileList = new TileList(); myTileList.addItem({label:"Image 1", source:baseURL + "image1.jpg"}); myTileList.addItem({label:"Image 2", source:baseURL + "image2.jpg"}); myTileList.addItem({label:"Image 3", source:baseURL + "image3.jpg"}); myTileList.direction = ScrollBarDirection.VERTICAL; myTileList.columnWidth = 100; myTileList.rowHeight= 67; myTileList.columnCount = 1; myTileList.rowCount = 1; myTileList.move(10, 10); addChild(myTileList); 

iconField property  
iconField:String  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the item field that provides the icon for the item.

Note: The iconField is not used if the iconFunction property is set to a callback function.

Icons can be classes or they can be symbols from the library that have a class name.

The default value is null.


Implementation
    public function get iconField():String
    public function set iconField(value:String):void

See also


Example

The following example creates an icon beside the label of each item in a tile list. The icon must be a symbol in the library named MyIcon with "Export for ActionScript" toggled in its symbol properties:
import fl.controls.TileList; import fl.controls.listClasses.CellRenderer;  var baseURL:String = "http://www.helpexamples.com/flash/images/";  var myTileList:TileList = new TileList(); myTileList.addItem({src:baseURL + "image1.jpg", iconSrc:MyIcon }); myTileList.addItem({src:baseURL + "image2.jpg", iconSrc:MyIcon }); myTileList.addItem({src:baseURL + "image3.jpg", iconSrc:MyIcon }); myTileList.labelField = "src"; myTileList.labelFunction = myLabelFunction; myTileList.setStyle('cellRenderer', CellRenderer);     myTileList.iconField = "iconSrc"; myTileList.columnWidth = 100; myTileList.rowHeight = 67; myTileList.columnCount = myTileList.length; myTileList.rowCount = 1; myTileList.move(10, 10); addChild(myTileList);  function myLabelFunction(item:Object):String {     var fileName:String = item.src;     var filePath:Array = fileName.split("/");     return filePath.pop(); }

iconFunction property  
iconFunction:Function  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the function to be used to obtain the icon for the item.

Note: The iconField is not used if the iconFunction property is set to a callback function.

Icons can be classes, or they can be library items that have class names.

The default value is null.


Implementation
    public function get iconFunction():Function
    public function set iconFunction(value:Function):void

See also


Example

The following example creates an icon beside only the second item of a tile list by using a function to determine if image2.jpg is the source of the item. The icon must be a symbol in the library named MyIcon with "Export for ActionScript" toggled in its symbol properties:
import fl.controls.TileList; import fl.controls.listClasses.CellRenderer;  var baseURL:String = "http://www.helpexamples.com/flash/images/";  var myTileList:TileList = new TileList(); myTileList.addItem({src:baseURL + "image1.jpg" }); myTileList.addItem({src:baseURL + "image2.jpg" }); myTileList.addItem({src:baseURL + "image3.jpg" }); myTileList.labelField = "src"; myTileList.labelFunction = myLabelFunction; myTileList.setStyle('cellRenderer', CellRenderer);     myTileList.iconFunction = myIconFunction; myTileList.columnWidth = 100; myTileList.rowHeight = 67; myTileList.columnCount = myTileList.length; myTileList.rowCount = 1; myTileList.move(10, 10); addChild(myTileList);  function myLabelFunction(item:Object):String {     var fileName:String = item.src;     var filePath:Array = fileName.split("/");     return filePath.pop(); }  function myIconFunction(item:Object):Class {     if(item.src == baseURL + "image2.jpg") {         return MyIcon;     }     else {         return null;     } }

innerHeight property  
innerHeight:Number  [read-only]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets the height of the content area, in pixels. This value is the component height minus the combined height of the contentPadding value and horizontal scroll bar height, if the horizontal scroll bar is visible.


Implementation
    public function get innerHeight():Number

See also

innerWidth property  
innerWidth:Number  [read-only]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets the width of the content area, in pixels. This value is the component width minus the combined width of the contentPadding value and vertical scroll bar, if the vertical scroll bar is visible.


Implementation
    public function get innerWidth():Number

See also


Example

The following example creates a TileList componenent instance and traces its innerWidth and innerHeight properties whenever the component's resize event is dispatched:
import fl.controls.ScrollBarDirection; import fl.controls.TileList; import fl.events.ComponentEvent;  var baseURL:String = "http://www.helpexamples.com/flash/images/";  var myTileList:TileList = new TileList(); myTileList.addItem({label:"Image 1", source:baseURL + "image1.jpg"}); myTileList.addItem({label:"Image 2", source:baseURL + "image2.jpg"}); myTileList.addItem({label:"Image 3", source:baseURL + "image3.jpg"}); myTileList.direction = ScrollBarDirection.VERTICAL; myTileList.addEventListener(ComponentEvent.RESIZE, resizeHandler); myTileList.columnWidth = 100; myTileList.rowHeight= 67; myTileList.columnCount = 1; myTileList.rowCount = 1; myTileList.move(10, 10); addChild(myTileList);  function resizeHandler(event:ComponentEvent):void {     var myTL:TileList =  event.currentTarget as TileList;     trace("resize:");     trace("\t" + "width:", myTL.width);     trace("\t" + "height:", myTL.height);     trace("\t" + "innerHeight:", myTL.innerHeight);     trace("\t" + "innerWidth:", myTL.innerWidth); } 

labelField property  
labelField:String  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets a field in each item that contains a label for each tile.

Note: The labelField is not used if the labelFunction property is set to a callback function.

The default value is "label".


Implementation
    public function get labelField():String
    public function set labelField(value:String):void

See also


Example

The following example creates a TileList component instance and sets the labelField and sourceField properties:
import fl.controls.TileList; import fl.data.DataProvider;  var imagesXML:XML = <images>         <img src="http://www.helpexamples.com/flash/images/image1.jpg" alt="Image 1" />         <img src="http://www.helpexamples.com/flash/images/image2.jpg" alt="Image 2" />         <img src="http://www.helpexamples.com/flash/images/image3.jpg" alt="Image 3" />     </images>;  var dp:DataProvider = new DataProvider(imagesXML);  var myTileList:TileList = new TileList(); myTileList.dataProvider = dp; myTileList.labelField = "alt"; myTileList.sourceField = "src"; myTileList.move(10, 10); addChild(myTileList); 

labelFunction property  
labelFunction:Function  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets a function that indicates the fields of an item that provide the label text for a tile.

Note: The labelField is not used if the labelFunction property is set to a callback function.

The default value is null.


Implementation
    public function get labelFunction():Function
    public function set labelFunction(value:Function):void

See also


Example

The following example creates a TileList component instance and creates a custom label function that returns the file name of the image being loaded:
import fl.controls.TileList; import fl.data.DataProvider;  var imagesXML:XML = <images>         <img src="http://www.helpexamples.com/flash/images/image1.jpg" />         <img src="http://www.helpexamples.com/flash/images/image2.jpg" />         <img src="http://www.helpexamples.com/flash/images/image3.jpg" />     </images>;  var dp:DataProvider = new DataProvider(imagesXML);  var myTileList:TileList = new TileList(); myTileList.dataProvider = dp; myTileList.labelFunction = myLabelFunction; myTileList.sourceField = "src"; myTileList.columnWidth = 100; myTileList.rowHeight = 67;  myTileList.columnCount = 3; myTileList.rowCount = 1; myTileList.move(10, 10); addChild(myTileList);  function myLabelFunction(item:Object):String {     var fileName:String = item.src;     var filePath:Array = fileName.split("/");     return filePath.pop(); } 

maxHorizontalScrollPosition property  
maxHorizontalScrollPosition:Number  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets the maximum horizontal scroll position for the current content, in pixels.


Implementation
    public function get maxHorizontalScrollPosition():Number
    public function set maxHorizontalScrollPosition(value:Number):void

See also

rowCount property  
rowCount:uint  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the number of rows that are at least partially visible in the list.

Setting the rowCount property changes the height of the list, but the TileList component does not maintain this value. It is important to set the rowCount value after setting the dataProvider and rowHeight values. The only exception is if the rowCount is set with the Property inspector; in this case, the property is maintained until the component is first drawn.

The default value is 0.


Implementation
    public function get rowCount():uint
    public function set rowCount(value:uint):void

See also


Example

The following example creates a TileList component instance and sets the columnCount and rowCount properties to create a grid of images:
import fl.controls.TileList; import fl.data.DataProvider;  var baseURL:String = "http://www.helpexamples.com/flash/images/gallery1/thumbnails/";  var imagesArray:Array = new Array(); var i:uint; for (i = 20; i < 30; i++) {     imagesArray.push({source:baseURL + "pic" + i + ".jpg", label:"Image " + i}); }  var dp:DataProvider = new DataProvider(imagesArray);  var myTileList:TileList = new TileList(); myTileList.dataProvider = dp; myTileList.columnWidth = 150; myTileList.rowHeight = 100;  myTileList.columnCount = 3; myTileList.rowCount = 2; myTileList.move(10, 10); addChild(myTileList); 

rowHeight property  
rowHeight:Number  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the height that is applied to each row in the list, in pixels.

The default value is 50.


Implementation
    public function get rowHeight():Number
    public function set rowHeight(value:Number):void

See also


Example

The following example creates a TileList component instance and displays the specified images in a 2x2 grid:
import fl.controls.TileList;  var baseURL:String = "http://www.helpexamples.com/flash/images/";  var myTileList:TileList = new TileList(); myTileList.addItem({label:"Image 1", source:baseURL + "image1.jpg"}); myTileList.addItem({label:"Image 2", source:baseURL + "image2.jpg"}); myTileList.addItem({label:"Image 3", source:baseURL + "image3.jpg"}); myTileList.columnWidth = 100; myTileList.rowHeight = 67; myTileList.columnCount = 2; myTileList.rowCount = 2; myTileList.move(10, 10); addChild(myTileList); 

scrollPolicy property  
scrollPolicy:String  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the scroll policy for the TileList component. This value is used to specify the scroll policy for the scroll bar that is set by the direction property.

Note: The TileList component supports scrolling only in one direction. Tiles are adjusted to fit into the viewable area of the component, so that tiles are hidden in only one direction.

The TileList component resizes to fit tiles only when the user manually sets the size or when the user sets the rowCount or columnCount properties.

When this value is set to ScrollPolicy.AUTO, the scroll bar is visible only when the TileList component must scroll to show all the items.

The default value is ScrollPolicy.AUTO.


Implementation
    public function get scrollPolicy():String
    public function set scrollPolicy(value:String):void

See also


Example

The following example creates a TileList component instance and sets the scrollPolicy to be always on:
import fl.controls.ScrollPolicy; import fl.controls.TileList;  var baseURL:String = "http://www.helpexamples.com/flash/images/";  var myTileList:TileList = new TileList(); myTileList.addItem({label:"Image 1", source:baseURL + "image1.jpg"}); myTileList.addItem({label:"Image 2", source:baseURL + "image2.jpg"}); myTileList.addItem({label:"Image 3", source:baseURL + "image3.jpg"}); myTileList.columnWidth = 100; myTileList.rowHeight = 67; myTileList.scrollPolicy = ScrollPolicy.ON; myTileList.columnCount = 4; myTileList.rowCount = 1; myTileList.move(10, 10); addChild(myTileList); 

sourceField property  
sourceField:String  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the item field that provides the source path for a tile.

Note: The sourceField is not used if the sourceFunction property is set to a callback function.

The default value is "source".


Implementation
    public function get sourceField():String
    public function set sourceField(value:String):void

See also


Example

The following example creates a TileList component instance and sets the labelField and sourceField properties:
import fl.controls.ScrollPolicy; import fl.controls.TileList;  var baseURL:String = "http://www.helpexamples.com/flash/images/";  var myTileList:TileList = new TileList(); myTileList.addItem({alt:"Image 1", src:baseURL + "image1.jpg"}); myTileList.addItem({alt:"Image 2", src:baseURL + "image2.jpg"}); myTileList.addItem({alt:"Image 3", src:baseURL + "image3.jpg"}); myTileList.labelField = "alt"; myTileList.sourceField = "src"; myTileList.columnWidth = 100; myTileList.rowHeight = 67; myTileList.columnCount = myTileList.length; myTileList.rowCount = 1; myTileList.move(10, 10); addChild(myTileList); 

sourceFunction property  
sourceFunction:Function  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the function to be used to obtain the source path for a tile.

Note: The sourceField is not used if the sourceFunction property is set to a callback function.

The default value is null.


Implementation
    public function get sourceFunction():Function
    public function set sourceFunction(value:Function):void

See also


Example

The following example creates a TileList component instance and sets the sourceFunction property:
import fl.controls.ScrollPolicy; import fl.controls.TileList;  var baseURL:String = "http://www.helpexamples.com/flash/images/";  var myTileList:TileList = new TileList(); myTileList.addItem({src:"image1.jpg"}); myTileList.addItem({src:"image2.jpg"}); myTileList.addItem({src:"image3.jpg"}); myTileList.labelField = "src"; myTileList.sourceFunction = mySourceFunction; myTileList.columnWidth = 100; myTileList.rowHeight = 67; myTileList.columnCount = myTileList.length; myTileList.rowCount = 1; myTileList.move(10, 10); addChild(myTileList);  function mySourceFunction(item:Object):String {     return baseURL + item.src; } 

Constructor Detail

TileList () Constructor
public function TileList()
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Creates a new List component instance.

Method Detail

getStyleDefinition () method
public static function getStyleDefinition():Object
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Retrieves the default style map for the current component. The style map contains the type that is appropriate for the component, depending on the style that the component uses. For example, the disabledTextFormat style contains a value of null or a TextFormat object. You can use these styles and call setStyle() on the current component. The following code overrides the default disabledTextFormat style on the specified component:

componentInstance.setStyle("disabledTextFormat", new TextFormat());

 

Returns
  Object — Default styles object.

See also


Example

The following example creates a style browser for several component classes:
import fl.controls.*; import fl.containers.*; import fl.controls.listClasses.*; import fl.controls.dataGridClasses.*; import fl.controls.progressBarClasses.*; import fl.core.UIComponent; import fl.data.DataProvider;  var dp:DataProvider = new DataProvider(); dp.addItem( { label: "BaseScrollPane",    data:BaseScrollPane } ); dp.addItem( { label: "Button",             data:Button } ); dp.addItem( { label: "CellRenderer",    data:CellRenderer } ); dp.addItem( { label: "CheckBox",         data:CheckBox } ); dp.addItem( { label: "ColorPicker",     data:ColorPicker } ); dp.addItem( { label: "ComboBox",         data:ComboBox } ); dp.addItem( { label: "DataGrid",         data:DataGrid } ); dp.addItem( { label: "HeaderRenderer",    data:HeaderRenderer } ); dp.addItem( { label: "ImageCell",        data:ImageCell } ); dp.addItem( { label: "IndeterminateBar",data:IndeterminateBar } ); dp.addItem( { label: "Label",             data:Label } ); dp.addItem( { label: "List",             data:List } ); dp.addItem( { label: "NumericStepper",     data:NumericStepper } ); dp.addItem( { label: "ProgressBar",     data:ProgressBar } ); dp.addItem( { label: "RadioButton",     data:RadioButton } ); dp.addItem( { label: "ScrollPane",         data:ScrollPane } ); dp.addItem( { label: "Slider",             data:Slider } ); dp.addItem( { label: "TextArea",         data:TextArea } ); dp.addItem( { label: "TextInput",         data:TextInput } ); dp.addItem( { label: "TileList",         data:TileList } ); dp.addItem( { label: "UILoader",         data:UILoader } ); dp.addItem( { label: "UIComponent",     data:UIComponent } );  var cb:ComboBox = new ComboBox(); cb.move(10,10); cb.setSize(300,25); cb.prompt = "Select a component to view its styles"; cb.rowCount = 12; cb.dataProvider = dp; cb.addEventListener(Event.CHANGE, showStyleDefinition); addChild(cb);  var dg:DataGrid = new DataGrid(); dg.setSize(425,300); dg.move(10,50); dg.columns = [ new DataGridColumn("StyleName"), new DataGridColumn("DefaultValue") ]; addChild(dg);  function showStyleDefinition(e:Event):void {     var componentClass:Class = e.target.selectedItem.data as Class;     var styles:Object = componentClass["getStyleDefinition"].call(this);     trace(styles.toString());     var styleData:DataProvider = new DataProvider();     for(var i:* in styles) {         trace(i + " : " + styles[i]);         styleData.addItem( { StyleName:i, DefaultValue:styles[i] } );     }     styleData.sortOn("StyleName");     dg.dataProvider = styleData; }

itemToLabel () method  
public override function itemToLabel(item:Object):String
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Retrieves the string that the renderer displays for a given data object based on the labelField and labelFunction properties.

Parameters

  item:Object — The Object to be rendered.
Returns
  String — The string to be displayed based on the data.

See also

scrollToIndex () method  
public override function scrollToIndex(newCaretIndex:int):void
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Scrolls the list to the item at the specified index. If the index is out of range, the scroll position does not change.

 

Parameters

  newCaretIndex:int — The index location to scroll to.

Example

The following example creates a TileList component instance and uses a Slider component to scroll through the images:
import fl.controls.ScrollPolicy; import fl.controls.Slider; import fl.controls.TileList; import fl.data.DataProvider; import fl.events.SliderEvent;  var dp:DataProvider = new DataProvider(); dp.addItem({label:"Image 1", source:"http://www.helpexamples.com/flash/images/image1.jpg"}); dp.addItem({label:"Image 2", source:"http://www.helpexamples.com/flash/images/image2.jpg"}); dp.addItem({label:"Image 3", source:"http://www.helpexamples.com/flash/images/image3.jpg"}); dp.addItem({label:"Image 4", source:"http://www.helpexamples.com/flash/images/image1.jpg"}); dp.addItem({label:"Image 5", source:"http://www.helpexamples.com/flash/images/image2.jpg"}); dp.addItem({label:"Image 6", source:"http://www.helpexamples.com/flash/images/image3.jpg"});  var myTileList:TileList = new TileList(); myTileList.dataProvider = dp; myTileList.scrollPolicy = ScrollPolicy.OFF; myTileList.columnWidth = 100; myTileList.rowHeight = 67; myTileList.columnCount = 3; myTileList.rowCount = 1; myTileList.move(10, 10); addChild(myTileList);  var mySlider:Slider = new Slider(); mySlider.liveDragging = true; mySlider.minimum = 0; mySlider.maximum = dp.length - 1; mySlider.snapInterval = 1; mySlider.tickInterval = 1; mySlider.width = myTileList.width; mySlider.move(myTileList.x, myTileList.y + myTileList.height + 10); mySlider.addEventListener(SliderEvent.CHANGE, changeHandler); addChild(mySlider);  function changeHandler(event:SliderEvent):void {     myTileList.scrollToIndex(event.value); } 

TileListExample.as

This example demonstrates how to create a TileList instance and dynamically populate its contents with a symbol from the library.

To run the example, follow these steps:

  1. Add the TileList component to the library.
  2. Draw a star and create a movie clip symbol from it named "star".
  3. In the symbol properties for star, check the box that says "Export for ActionScript".
  4. Save this code as TileListExample.as in the same directory as your FLA file.
  5. Set the Document class in the FLA file to TileListExample.
package {      import fl.controls.TileList;     import fl.data.DataProvider;     import flash.display.Sprite;     import flash.events.Event;          public class TileListExample extends Sprite     {         public function TileListExample() {             var dp:DataProvider = new DataProvider();             var totalEntries:uint = 42;             var i:uint;             for(i=0; i<totalEntries; i++) {                 dp.addItem( { label:"star"+i, source:star, scaleContent:false} );                         }                          var myTileList:TileList = new TileList();             myTileList.allowMultipleSelection = true;             myTileList.columnWidth = 125;             myTileList.rowHeight = 150;             myTileList.dataProvider = dp;             myTileList.columnCount = 3;             myTileList.rowCount = 1;             myTileList.move(10,10);             addChild(myTileList);         }     } }
 //----------------------------------------------------------------------------------------------------------
 
 출처: http://www.13580.com/docs/ActionScriptLangRefV3/fl/controls/listClasses/ICellRenderer.html
Property Detail
data property
data:Object  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets an Object that represents the data that is associated with a component. When this value is set, the component data is stored and the containing component is invalidated. The invalidated component is then automatically redrawn.

The data property represents an object containing the item in the DataProvider that the cell represents. Typically, the data property contains standard properties, depending on the component type. In CellRenderer in a List or ComboBox component the data contains a label, icon, and data properties; a TileList: a label and a source property; a DataGrid cell contains values for each column. The data property can also contain user-specified data relevant to the specific cell. Users can extend a CellRenderer for a component to utilize different properties of the data in the rendering of the cell.

Additionally, the labelField, labelFunction, iconField, iconFunction, sourceField, and sourceFunction elements can be used to specify which properties are used to draw the label, icon, and source respectively.


Implementation
    public function get data():Object
    public function set data(value:Object):void
listData property  
listData:ListData  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets the list properties that are applied to the cell--for example, the index and selected values. These list properties are automatically updated after the cell is invalidated.


Implementation
    public function get listData():ListData
    public function set listData(value:ListData):void
selected property  
selected:Boolean  [read-write]
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Gets or sets a Boolean value that indicates whether the current cell is selected. A value of true indicates that the current cell is selected; a value of false indicates that it is not.


Implementation
    public function get selected():Boolean
    public function set selected(value:Boolean):void
Method Detail
setMouseState () method
public function setMouseState(state:String):void
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Sets the current cell to a specific mouse state. This method is necessary for the DataGrid to set the mouse state on an entire row when the user interacts with a single cell.

Parameters

  state:String — A string that specifies a mouse state, such as "up" or "over".
setSize () method  
public function setSize(width:Number, height:Number):void
Language Version :  ActionScript 3.0
Player Version :  Flash Player 9.0.28.0

Sets the size of the data according to the pixel values specified by the width and height parameters.

Parameters

  width:Number — The width to display the cell renderer at, in pixels.
 
  height:Number — The height to display the cell renderer at, in pixels.
ICellRendererExample.as

This example creates a custom cell renderer by implementing the ICellRenderer class.

To run the example, follow these steps:

  1. Add the List and Button components to the library.
  2. Save this code as ICellRendererExample.as in the same directory as your FLA file.
  3. Set the Document class in the FLA file to ICellRendererExample.
package {      import fl.controls.List;     import fl.data.DataProvider;     import fl.events.ListEvent;     import flash.display.Sprite;     import flash.events.Event;          public class ICellRendererExample extends Sprite     {         public function ICellRendererExample() {             var dp:DataProvider = new DataProvider();             var totalEntries:Number = 42;             var i:Number;             for(i=0; i<totalEntries; i++) {                 dp.addItem( { label:Math.random(), data:null } );                         }                          var myList = new List();             myList.setSize(300,300);             myList.move(10,10);             myList.setStyle('cellRenderer', MyRenderer);                 myList.dataProvider = dp;             addChild(myList);         }     } }
MyRenderer.as

Save the following code as MyRenderer.as in the same directory as your FLA file:
package {     import fl.controls.LabelButton;     import fl.controls.listClasses.ICellRenderer;     import fl.controls.listClasses.ListData;          public class MyRenderer extends LabelButton implements ICellRenderer {         private var _listData:ListData;         private var _data:Object;                  public function MyRenderer() {         }          public function set listData(newListData:ListData):void {             _listData = newListData;             label = "Random: " + _listData.label;             drawRandomColor();         }          private function drawRandomColor():void {             graphics.beginFill(Math.random()*0xFFFFFF);             graphics.drawRect(0,0,20,20);             graphics.endFill();                     }          public function get listData():ListData {             return _listData;         }          public function set data(newData:Object):void {             _data = newData;         }          public function get data():Object {             return _data;         }     } }

 //---------------------------------------------------
 
 출처: http://www.kxcad.net/image_Adobe_Flash_ActionScript_Language_Reference_V3/fl/controls/listClasses/TileListData.html

This example illustrates how to access the TileListData object of an image cell in a tile list.

To run the example, follow these steps:

  1. Add the TileList component to the library.
  2. Save this code as TileListDataExample.as in the same directory as your FLA file.
  3. Set the Document class in the FLA file to TileListDataExample.
package  {     import fl.controls.TileList;     import fl.controls.listClasses.ImageCell;     import fl.controls.listClasses.TileListData;     import fl.data.DataProvider;     import fl.events.ListEvent;     import flash.display.Sprite;     import flash.events.Event;     import flash.text.TextField;     import flash.text.TextFieldAutoSize;              public class TileListDataExample extends Sprite     {         var sourceClasses:Array = [ RedBox, GreenBox, BlueBox ];         var myTileList:TileList;         var tf:TextField;          public function TileListDataExample() {             createList();              tf = new TextField();             tf.x = 10;             tf.y = 10;             tf.autoSize = TextFieldAutoSize.LEFT;             addChild(tf);         }         private function createList():void {             myTileList = new TileList();             myTileList.move(10,40);             myTileList.addEventListener(ListEvent.ITEM_CLICK,itemSelected);                          var dp:DataProvider = new DataProvider();             var i:uint;             for(i=0; i<42; i++) {                 dp.addItem( { label:"Item " + i, source:getRandomImageCellSource() } );             }             myTileList.dataProvider = dp;             myTileList.rowCount = 3;             myTileList.columnCount = 7;                          addChild(myTileList);         }         private function itemSelected(e:ListEvent):void {             var renderer:ImageCell = myTileList.itemToCellRenderer(e.item) as ImageCell;             var listData:TileListData = renderer.listData as TileListData;              tf.text = "You have clicked an item that uses " + listData.source + " for a source.";         }         private function getRandomImageCellSource():Class {             return sourceClasses[Math.floor(Math.random()*sourceClasses.length)];         }     } }  import flash.display.Sprite;  class RedBox extends Sprite {     public function RedBox() {         graphics.beginFill(0x990000);         graphics.drawRect(0,0,100,100);     } } class GreenBox extends Sprite {     public function GreenBox() {         graphics.beginFill(0x009900);         graphics.drawRect(0,0,100,100);     } }     class BlueBox extends Sprite {     public function BlueBox() {         graphics.beginFill(0x000099);         graphics.drawRect(0,0,100,100);     } }        
 
 //------------------------------------------------------------
 기타 링크
 http://www.broderjakob.se/2009/04/29/copying-a-movieclip-in-as3/
 http://stackoverflow.com/questions/3127329/how-to-create-a-custom-cell-renderer-for-a-tile-list-in-flash
 셀단위 리스트
 http://www.13580.com/docs/ActionScriptLangRefV3/fl/controls/listClasses/CellRenderer.html
 데이타그리드
 http://as3.blue112.eu/fl/data/DataProvider.html 
 http://www.22answers.com/posts/answers/en/3195816

 

 

 

=================================

=================================

=================================

 

 

반응형