Hi,

Where do you want to attach the component. If it's a container, you can use

contianerRef.createChild( customComponentName, name: String, initProps:
Object)

Can you please tell us, why would want to attach Custom Component using
ActionScript in Repeater?


You can do in clean approach using MXML & binding, as shown below...

##MyCustomComponent.mxml###

<mx:HBox xmlns:mx="http://www.macromedia.com/2003/mxml";>
<mx:Script>
<![CDATA[
        var itemLabel:String;
        var itemText:String;
        
        
]]>
</mx:Script>
<mx:Label id="_lbl" text="{itemLabel}"></mx:Label>
<mx:TextInput id="_ti" text="{itemText}"></mx:TextInput>
</mx:HBox>


##MainApp.mxml###

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";
backgroundColor="#FFFFFF" xmlns:local="*">

        <mx:Script>
                <![CDATA[
            
                        var dp:Array = [{label:"Name", data:"Abdul"},
{label:"Name", data:"Manish"}];
                        
                        function onCC()
                        {
                            createChild(MyComponent, "SS");
                        }

                        
                ]]>
        </mx:Script>

  <mx:Panel title="Repeater Panel">
  
    <mx:Tile marginBottom="10" borderStyle="inset" verticalGap="15"
id="myFlow"
        marginLeft="10" backgroundColor="#FFFFCC" marginTop="10"
marginRight="10"
        horizontalGap="10" direction="horizontal" autoLayout="false"
clipContent="false" >
        
                <mx:Repeater  id="rp" dataProvider="{dp}" >
                        
                        <local:MyCustomComponent
itemLabel="{rp.currentItem.label}" itemText="{rp.currentItem.data}"/>
                        
                </mx:Repeater>
    
        </mx:Tile>
  
  </mx:Panel>
  
</mx:Application>



Hope that helps,

-abdul 

-----Original Message-----
From: Jack Waknitz [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 24, 2005 4:47 AM
To: [email protected]
Subject: [flexcoders] Attaching Custom Component


I am trying to figure out how to attach a custom component to an
application using actionscript.  I'm using a repeater with a function
on the repeat event.  Inside that function what would I do to create
the custom component that I have?  .mxml file using mxml.

-- 
  [ Jack ]


 
Yahoo! Groups Links



 





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to