".row into a master component and stick it in the Repeater." Precisely.
And here are some snippets that might help, it is simpler than what you want
to do, but is a start.
..........
Goal: Display a list of items using a complex display for each item, and
have each of those items behave like a menu element and respond to a click
anywhere on the item by running a handler function.
One solution is to use a Repeater with a custom component
In the main app or component, declare the Repeater, and the click handler
function.
<mx:Application ...
<mx:Script><![CDATA[
import MyRepeaterItem;
...
private function onRPItemClick(oEvent:Event):void
{
var xmlItem:XML = XML(oEvent.target);
}//onRPItemClick
]]></mx:Script>
<mx:VBox ...>
<mx:Repeater id="rp" dataProvider="{_xmlData}" ...>
<!-- Note we pass in the entire currentItem, and define a click
handler -->
<MyRepeaterItem xmlItem="{rp.currentItem}"
itemClick="onRPItemClick(event)" .../>
</mx:Repeater
</mx:VBox>
</mx:Application>
And in the component, MyRepeaterItem.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox mouseChildren="false" buttonMode="true" click="onClick(event)" >
<!-- The metadata tag below allows us to define an itemClick handler in
mxml, as in the code above -->
<mx:Metadata>
[Event(name="itemClick", type="flash.events.Event")]
</mx:Metadata>
<mx:Script><![CDATA[
[Bindable]private var _xmlItem:XML;
/** Setter function */
public function set xmlItem(xml:XML):void
{
_xmlItem = xml;
//do any special, non-bound ui stuff you want
}//set xmlItem
/** Getter function */
public function get xmlItem():XML
{
return _xmlItem;
}//get xmlItem
/** Outer VBox Click handler function */
private function onClick():void
{
dispatchEvent(new Event("itemClick",false); //we do not need/want this
event to bubble
}//onClick
]]></mx:Script>
<!-- Now declare the Item UI -->
<mx:Text id="lbDescription" text="{_xmlit...@description}" width="100%"
height="100%" />
</mx:HBox>
Tracy Spratt,
Lariat Services, development services available
_____
From: [email protected] [mailto:[email protected]] On
Behalf Of Brad Bueche
Sent: Sunday, June 14, 2009 9:06 PM
To: [email protected]
Subject: Re: [flexcoders] Re: Dynamically Naming Objects
Ok, thanks for the underscore there, Tracy. Sounds like exactly what I
need. Basically, at a simple level I'm extending that searchcoders search
interface to a full adhoc query front end. So the plus minus buttons will
add a row that will have combo-boxes with the data providers --both static
and from a db -- and text entry boxes. So each row will actually be a
series of sub- components. So I guess I could turn the row into a master
component and stick it in the Repeater. I'll have to look into all these
goodies that the Repeater provides.
thanks again!
brad
On Sun, Jun 14, 2009 at 6:43 PM, Tracy Spratt <tr...@nts3rd.
<mailto:[email protected]> com> wrote:
".thought of the Repeater as a simple grid creator ." That is completely
wrong. Repeater has *no* layout functionality at all. It is simply a
replacement for addChild/ removeChild, with a lot of extra and useful
functionality like optional recycling and automatic creation of an array of
references via the id (myId[n]).
Look into Repeater before you write all of that code manually.
One suggestion: do not write any but the simplest repeated content
'in-line'. Instead, create a custom component and repeat that, passing in
the entire currentItem via a setter function. You will find this much
easier to code, especially dispatching events, etc.
Tracy Spratt,
Lariat Services, development services available
_____
From: flexcod...@yahoogro <mailto:[email protected]> ups.com
[mailto:flexcod...@yahoogro <mailto:[email protected]> ups.com] On
Behalf Of Brad Bueche
Sent: Sunday, June 14, 2009 6:11 PM
To: flexcod...@yahoogro <mailto:[email protected]> ups.com
Subject: Re: [flexcoders] Re: Dynamically Naming Objects
Thanks, Amy, I didnt think about that. I've always thought of the Repeater
as a simple grid creator but I guess I'll have to read up on it.
brad
On Sun, Jun 14, 2009 at 11:57 AM, Amy <amyblankenship@
<mailto:[email protected]> bellsouth.net> wrote:
--- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com,
Gordon Smith <gosm...@...> wrote:
>
> 1. If accessing the ComboBoxes you'll create by an index number is
sufficient, declare an instance var of type Array:
>
> private var comboBoxes:Array = [];
>
> When you dynamically create a new ComboBox, simply add the reference onto
the end of this Array:
Or you can use a repeater, which automates this and will automatically
handle destroying and recreating all the comboboxes if the data source they
are based on changes.