topical media & game development 
  
 
 
 
 
  
    
    
  
professional-flex-code-08-BasicRepeater.mx
professional-flex-code-08-BasicRepeater.mx
[swf]
 
 flex
  <?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
     backgroundColor="#FFFFFF">
    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    // handle button click and show the objects data property
    private function clickHandler(item:Object):void {
      Alert.show(item.data, "ClickHandler");
    }
    ]]>
    </mx:Script>
    <mx:ArrayCollection id="dp">
      <mx:Object label="Button 1" data="Data 1" />
      <mx:Object label="Button 2" data="Data 2" />
      <mx:Object label="Button 3" data="Data 3" />
      <mx:Object label="Button 4" data="Data 4" />
    </mx:ArrayCollection>
    <mx:Panel title="Basic Repeater" layout="horizontal">
      <mx:Repeater id="myRepeater" dataProvider="{dp}" >
        <mx:Button label="{myRepeater.currentItem.label}" 
         click="clickHandler(event.currentTarget.getRepeaterItem());" />
      </mx:Repeater>
    </mx:Panel>
  </mx:Application>
  
  
  
(C) Æliens 
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher. 
In case of other copyright issues, contact the author.