I'm trying to make a app that will look through an xml file and decide what components to use for each <item> based on some meta data. So I'm thinking about puting the createChild tag within the function based on if statements to choose between a few different compontents to display the data. Can you think of a better way of doing this? Or do you think this is a good path? I was also thinking of just using a for loop instead of the repeater. Don't know how each will work.
Thanks for the help. On Wed, 23 Mar 2005 16:00:53 -0800, Abdul Qabiz <[EMAIL PROTECTED]> wrote: > 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 Sponsor > ADVERTISEMENT > > ________________________________ > 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 the Yahoo! Terms of Service. -- [ Jack ] 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/

