Hi,

I am trying to create a Repeater & execute it using
ActionScript. I have  corresponding mxml code
which executes correctly but the ActionScript code
doesn't seem to be doing anything on execution. I'm
not understanding how the repeater binding looks like
in ActionScript or if any additional thing needs to be
done.

Please help.

Thanks,
Aejaz

Here is the ActionScript code,

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
width="150" height="150" backgroundColor="#FFFFFF" borderStyle="solid" initialize="rTest()">
<mx:Script>
<![CDATA[
import mx.containers.FormItem;
import mx.containers.Form;
import mx.collections.ArrayCollection;
import mx.core.*;
import mx.controls.* ;
[Bindable]
public var myArray:Array=[{label:"A", value:"1"},
                                                           {label:"B", value:"2"}];                         
private function rTest():void
{
    var ac:ArrayCollection = new ArrayCollection(myArray);
    var rep:Repeater = new Repeater();
    rep.dataProvider = ac ;
    var form:Form = new Form();
    var form_item:FormItem = new FormItem();
    var btn:Button = new Button();
    var label:Label = new Label();
    label.text = rep.currentItem.label ;
    form_item.addChild(label);
    btn.label = rep.currentItem.value ;
    form_item.addChild(btn);
    rep.addChild(form_item);
    form.addChild(rep);
    this.addChild(form);   
    rep.initializeRepeater(this, true);
    rep.executeChildBindings();
}
]]>
</mx:Script>
</mx:Application>

The same thing in MXML which works fine,

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
width="150" height="150" backgroundColor="#FFFFFF" borderStyle="solid" >
<mx:Script>
<![CDATA[

[Bindable]
public var myArray:Array=[{label:"A", value:"1"},
                                                            {label:"B", value:"2"}];   
                       
]]>
</mx:Script>
<mx:Form label="TestForm" >
        <mx:Repeater  id="myrep" dataProvider="{new ArrayCollection(myArray)}">
            <mx:FormItem label="{myrep.currentItem.label}">
            <mx:Button label="{myrep.currentItem.value}"/>
            </mx:FormItem>
        </mx:Repeater>              
</mx:Form>

</mx:Application>
__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to