The MXML compiler handles all this for you automatically, you don't need to
do anything special for your component to support "nesting". Actually all
this MXML represents is a property assignment. Notice how <mx:request> has
a lowercase "r". That indicates it's a property of HTTPService, not a
component itself. The stuff inside that is an XML object (in this
particular case) which is translated by the MXML compiler from MXML to AS3
and at runtime assigned to the HTTPService.request property.
Another method of "nesting" which is still really just property assignments
is when one UI control is placed within another. This is accomplished when
a component declares one of it's properties as UIComponent or IUIComponent
or DisplayObject or any other visual base class. Even better would be to
declare the property as IDeferredInstance and then you can take advantage of
lazy instantiation.
I think passing around id's is a very bad idea.. will lead to maintenance
nightmares. Delcaring properties of type UIComponent or whatever (use a
more specific type if appropriate) will give you much better results and
then you can link things with bindings. The validators give a good example
of best practices in this area..
<mx:TextInput id="someText" />
<mx:Validator source="{someText}" />
HTH,
Sam
-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building Flex
based products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
On Behalf Of k2tam
Sent: Monday, August 13, 2007 7:47 PM
To: [email protected]
Subject: [flexcomponents] Nesting non-visual components/elements?
How does one implement nested nonvisual components in AS3? For
example, the HTTPService component (the one in the mxml package)
allows the following syntax:
<mx:HTTPService>
<mx:request>
//... e.g. some XML
</mx:request>
</mx:HTTPService>
The docs for mx.rpc.http.mxml.HTTPService say that it implements
IMXMLObject and IXMLObjectSupport, which basically gives me the
"initialized" callback when my properties are set, but there's nothing
that discusses defining, validating, or accessing nested
components/elements. I can't even find distinct documentation for
<mx:request>.
In the absence of nesting, anyone have thoughts on best practices for
hooking up related nonvisual components? Right now I am linking them
by passing around IDs and using document[<id of dependency>] inside
the initialized method, but it's definitely a bit hacky. At minimum
it would be nice to require that a property be set (semantically
modelling a required dependency).. is that possible?
cheers,
ken