Repeater Class

Adobe Platform/Flex 2012. 9. 10. 17:20

 

Repeater클래스는 <mx:Repeater>태그에 반응하는 runtime클래스입니다. Repeater클래스는 dataProvider기반의 하위컴포넌트를 가지는 다수의 인스턴스를 생성합니다.

The Repeater class is the runtime object that corresponds to the <mx:Repeater> tag. It creates multiple instances of its subcomponents based on its dataProvider. The repeated components can be any standard or custom controls or containers.

<mx:Application>컨테이너 태그를 제외한, 컨트롤태그나 컨테이너태그 어디서든 <mx:Repeater>태그를 사용할 수 있습니다. 사용자인터페이스 컴포넌트를 반복시키려면, <mx:Repeater>태그안에 위치시켜야 합니다. MXML문서안에서는 <mx:Repeater>태그를 여러번 쓸 수 있습니다. 또한 nest태그(<mx:Repeater></mx:Repeater>)로도 쓸 수 있습니다.

UIComponent클래스를 확장하지 않은 객체에서는 <mx:Repeater>태그를 사용할 수 없습니다.

You can use the <mx:Repeater> tag anywhere a control or container tag is allowed, with the exception of the <mx:Application> container tag. To repeat a user interface component, you place its tag in the <mx:Repeater> tag. You can use more than one <mx:Repeater> tag in an MXML document. You can also nest <mx:Repeater> tags.

You cannot use the <mx:Repeater> tag for objects that do not extend the UIComponent class.

 

   <mx:Repeater
    Properties
    id="No default"
    childDescriptors="No default"
    count="No default"
    dataProvider="No default"
    recycleChildren="false|true"
    startingIndex="0"

    Events
    repeat="No default"
    repeatEnd="No default"
    repeatStart="No default"
  >

 

<?xml version="1.0"?>

<!-- Simple example to demonstrate the Repeater class. -->

<s:Application name="RepeaterExample"

                       xmlns:fx="http://ns.adobe.com/mxml/2009"

                       xmlns:s="library://ns.adobe.com/flex/spark"

                       xmlns:mx="library://ns.adobe.com/flex/mx">

      

       <fx:Script>

             <![CDATA[

                    import mx.controls.Alert;

                   

                    [Bindable]

                    private var dp:Array = [1, 2, 3, 4, 5, 6, 7, 8, 9];   

                   

                    private function showAlert(evt:MouseEvent):void {

                           Alert.show(String(evt.currentTarget.getRepeaterItem()) + " pressed");

                    }

             ]]>

       </fx:Script>

      

       <s:Panel title="Repeater Example"

                     width="75%" height="75%"

                     horizontalCenter="0" verticalCenter="0">

             <s:VGroup left="10" right="10" top="10" bottom="10">

                    <s:Label width="100%" color="blue"

                                  text="Use the Repeater class to create 9 Button controls in a 3 by 3 Tile container."/>

                    <mx:Tile direction="horizontal" borderStyle="inset"

                                  horizontalGap="10" verticalGap="15"

                                  paddingLeft="10" paddingTop="10" paddingBottom="10" paddingRight="10">

                          

                           <mx:Repeater id="rp" dataProvider="{dp}">

                                 <s:Button height="49" width="50"

                                                label="{String(rp.currentItem)}"

                                                click="showAlert(event);"/>

                           </mx:Repeater>

                    </mx:Tile>

             </s:VGroup>

       </s:Panel>

      

</s:Application>

 

*source code :RepeaterExample.fxp

*source : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/Repeater.html#includeExamplesSummary

AND