[flexcoders] Re: How to compose a super tree item renderer using TreeItemRenderer and others

2008-06-20 Thread an0one
Fine. Can you just show me a simple example of how to Just add the label when 
you 
subclass. Real code is most convincing and helpful to me. And you blog is 
cool, but it 
just seems not so easy to dig up the specific snippet I need in a short time. 
Thank you 
again.
--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 There are no hard rules here.  I'm a code minimalist and don't like
 adding layers of code and display object parents unless it is really
 important.  Adding one child is not worthy of another layer IMHO, so I'd
 just subclass, and I don't see why such a subclass wouldn't be reusable.
 See the examples on my blog (blogs.adobe.com/aharui).
 
  
 
 The more stuff you add, the slower things get and more memory they take.
 MXML is convenient, but not as efficient.  It's up to you.  If you do
 composite, the trick should be propagating the data object from the
 container to the children.
 
  
 
 Also, you should never call addChild in a constructor.  We have a
 component lifecycle documented for performance reasons.




RE: [flexcoders] Re: How to compose a super tree item renderer using TreeItemRenderer and others

2008-06-20 Thread Alex Harui
Sorry, I don't have time to customize an example for you.  I recommend
looking at the differences between ListItemRenderer and TreeItemRenderer
as a start.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of an0one
Sent: Friday, June 20, 2008 8:59 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: How to compose a super tree item renderer
using TreeItemRenderer and others

 

Fine. Can you just show me a simple example of how to Just add the
label when you 
subclass. Real code is most convincing and helpful to me. And you blog
is cool, but it 
just seems not so easy to dig up the specific snippet I need in a short
time. Thank you 
again.
--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote:

 There are no hard rules here. I'm a code minimalist and don't like
 adding layers of code and display object parents unless it is really
 important. Adding one child is not worthy of another layer IMHO, so
I'd
 just subclass, and I don't see why such a subclass wouldn't be
reusable.
 See the examples on my blog (blogs.adobe.com/aharui).
 
 
 
 The more stuff you add, the slower things get and more memory they
take.
 MXML is convenient, but not as efficient. It's up to you. If you do
 composite, the trick should be propagating the data object from the
 container to the children.
 
 
 
 Also, you should never call addChild in a constructor. We have a
 component lifecycle documented for performance reasons.

 



[flexcoders] Re: How to compose a super tree item renderer using TreeItemRenderer and others

2008-06-19 Thread an0one
Do you mean defining a subclass of TreeItemRenderer and calling addChild() in 
its 
constructor? Then it seems not easy to position and resize the embeded controls 
intuitively. 
What's worse, this subclass is of course hard to reuse. 

And I just gave a simplified case. What if I want a super tree item renderer 
consisting of a 
ItemRendererA, a ItemRendererB, a ControlA, a ControlB, a ControlC ... ? Don't 
you think it is 
much more convenient and elegant to combine all these controls and standard 
item 
renderers in one container using mxml than to write a item renderer subclass in 
AS and fill it 
with all these stuffs as if it is a container?  (You should notice I have no 
hard logic to code 
here, but just a little layout composition to build and data bindings to make.)

Now that we have mxml as a nice layout framework, why don't we make it better 
and let 
developers combine all the available elements on it to build whatever they can 
imagine at 
will?
--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 Why composite?  Just add the label when you subclass.




RE: [flexcoders] Re: How to compose a super tree item renderer using TreeItemRenderer and others

2008-06-19 Thread Alex Harui
There are no hard rules here.  I'm a code minimalist and don't like
adding layers of code and display object parents unless it is really
important.  Adding one child is not worthy of another layer IMHO, so I'd
just subclass, and I don't see why such a subclass wouldn't be reusable.
See the examples on my blog (blogs.adobe.com/aharui).

 

The more stuff you add, the slower things get and more memory they take.
MXML is convenient, but not as efficient.  It's up to you.  If you do
composite, the trick should be propagating the data object from the
container to the children.

 

Also, you should never call addChild in a constructor.  We have a
component lifecycle documented for performance reasons.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of an0one
Sent: Thursday, June 19, 2008 6:45 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: How to compose a super tree item renderer
using TreeItemRenderer and others

 

Do you mean defining a subclass of TreeItemRenderer and calling
addChild() in its 
constructor? Then it seems not easy to position and resize the embeded
controls intuitively. 
What's worse, this subclass is of course hard to reuse. 

And I just gave a simplified case. What if I want a super tree item
renderer consisting of a 
ItemRendererA, a ItemRendererB, a ControlA, a ControlB, a ControlC ... ?
Don't you think it is 
much more convenient and elegant to combine all these controls and
standard item 
renderers in one container using mxml than to write a item renderer
subclass in AS and fill it 
with all these stuffs as if it is a container? (You should notice I have
no hard logic to code 
here, but just a little layout composition to build and data bindings to
make.)

Now that we have mxml as a nice layout framework, why don't we make it
better and let 
developers combine all the available elements on it to build whatever
they can imagine at 
will?
--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote:

 Why composite? Just add the label when you subclass.

 



[flexcoders] Re: How to compose a super tree item renderer using TreeItemRenderer and others

2008-06-18 Thread an0one
Being an AS class is not a compelling reason of not being able to be used as a 
mxml tag. 
Otherwise, why can I use a subclass of TreeItemRenderer in my mxml code(see my 
second 
example code)?
However, I am more anxious that you could tell me something about my second 
problem.
--- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote:

 TreeItemRenderer is an AS class, but not an mxml tag.
 
  
 
 You can't do a serious TreeItemRenderer in-line.
 
  
 
 See this example for a start:
 
 http://www.cflex.net/showFileDetails.cfm?ObjectID=575
 
  
 
 Tracy
 
  
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of an0one
 Sent: Tuesday, June 17, 2008 11:18 AM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] How to compose a super tree item renderer using
 TreeItemRenderer and others
 
  
 
 Hi,
 I want a custom tree item renderer that consists of a basic
 TreeItemRenderer(to reuse its 
 tree node icons) and several other standard controls(they are also
 IListItemRenderer 
 implementors). Let's call it ComboTreeItemRenderer, and to simplify the
 matters, assume 
 it is composed of a TreeItemRenderer and a Label.
 
 This is my first try:
 mx:Tree width=100% height=100% 
 id=tagTree 
 dataProvider={myTags} 
 change=handleTagSelection(event);
 mx:itemRenderer
 mx:Component
 mx:HBox
 mx:TreeItemRenderer
 /mx:TreeItemRenderer
 mx:Label text=[EMAIL PROTECTED]
 /mx:Label
 /mx:HBox
 /mx:Component
 /mx:itemRenderer
 /mx:Tree
 
 And the first error I met:
 Could not resolve mx:TreeItemRenderer to a component implementation.
 
 I don't believe TreeItemRenderer can not be used in mxml coding, so I
 guess I was just not 
 coding in the right way. But what's the right way then?
 
 However, that's not really what I was stumped by, since I found that I
 could write a custom 
 component(named MyTreeItemRenderer) which extends
 TreeItemRenderer(nothing to 
 override, just to work around the could no resolve error), and it
 could be resolved of 
 course. So here is my second try:
 mx:Tree width=100% height=100% 
 id=tagTree 
 dataProvider={myTags} 
 change=handleTagSelection(event);
 mx:itemRenderer
 mx:Component
 mx:HBox
 mx:MyTreeItemRenderer
 /mx:MyTreeItemRenderer
 mx:Label text=[EMAIL PROTECTED]
 /mx:Label
 /mx:HBox
 /mx:Component
 /mx:itemRenderer
 /mx:Tree
 
 Now comes the really difficulties: I know I must assign values to some
 properties of 
 MyTreeItemRenderer using information carried by data and listData, but
 what properties 
 to assign value to? And what makes me even crazier is that I found
 neither listData and 
 data was set(observed by overriding set listData and set data functions
 and find they were 
 never called).
 
 Looking forward to seeing helpful hints. Thanks in advance.






[flexcoders] Re: How to compose a super tree item renderer using TreeItemRenderer and others

2008-06-18 Thread an0one
I know how to create a subclass of TreeItemRenderer and use it as the 
itemRenderer of a 
Tree. What I can't quite figure out is how to create a composite tree item 
renderer 
enclosing a TreeItemRenderer and a Label. 
--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 You may need to bind the new renderer's .data to the TreeITemRenderer's
 .data property.
 
  
 
 I would just extend TreeItemRenderer and change what it does, though.
 
  
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of an0one
 Sent: Tuesday, June 17, 2008 8:18 AM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] How to compose a super tree item renderer using
 TreeItemRenderer and others
 
  
 
 Hi,
 I want a custom tree item renderer that consists of a basic
 TreeItemRenderer(to reuse its 
 tree node icons) and several other standard controls(they are also
 IListItemRenderer 
 implementors). Let's call it ComboTreeItemRenderer, and to simplify the
 matters, assume 
 it is composed of a TreeItemRenderer and a Label.
 
 This is my first try:
 mx:Tree width=100% height=100% 
 id=tagTree 
 dataProvider={myTags} 
 change=handleTagSelection(event);
 mx:itemRenderer
 mx:Component
 mx:HBox
 mx:TreeItemRenderer
 /mx:TreeItemRenderer
 mx:Label text=[EMAIL PROTECTED]
 /mx:Label
 /mx:HBox
 /mx:Component
 /mx:itemRenderer
 /mx:Tree
 
 And the first error I met:
 Could not resolve mx:TreeItemRenderer to a component implementation.
 
 I don't believe TreeItemRenderer can not be used in mxml coding, so I
 guess I was just not 
 coding in the right way. But what's the right way then?
 
 However, that's not really what I was stumped by, since I found that I
 could write a custom 
 component(named MyTreeItemRenderer) which extends
 TreeItemRenderer(nothing to 
 override, just to work around the could no resolve error), and it
 could be resolved of 
 course. So here is my second try:
 mx:Tree width=100% height=100% 
 id=tagTree 
 dataProvider={myTags} 
 change=handleTagSelection(event);
 mx:itemRenderer
 mx:Component
 mx:HBox
 mx:MyTreeItemRenderer
 /mx:MyTreeItemRenderer
 mx:Label text=[EMAIL PROTECTED]
 /mx:Label
 /mx:HBox
 /mx:Component
 /mx:itemRenderer
 /mx:Tree
 
 Now comes the really difficulties: I know I must assign values to some
 properties of 
 MyTreeItemRenderer using information carried by data and listData, but
 what properties 
 to assign value to? And what makes me even crazier is that I found
 neither listData and 
 data was set(observed by overriding set listData and set data functions
 and find they were 
 never called).
 
 Looking forward to seeing helpful hints. Thanks in advance.






RE: [flexcoders] Re: How to compose a super tree item renderer using TreeItemRenderer and others

2008-06-18 Thread Alex Harui
Why composite?  Just add the label when you subclass.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of an0one
Sent: Wednesday, June 18, 2008 7:22 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: How to compose a super tree item renderer
using TreeItemRenderer and others

 

I know how to create a subclass of TreeItemRenderer and use it as the
itemRenderer of a 
Tree. What I can't quite figure out is how to create a composite tree
item renderer 
enclosing a TreeItemRenderer and a Label. 
--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote:

 You may need to bind the new renderer's .data to the
TreeITemRenderer's
 .data property.
 
 
 
 I would just extend TreeItemRenderer and change what it does, though.
 
 
 
 
 
 From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
[mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
] On
 Behalf Of an0one
 Sent: Tuesday, June 17, 2008 8:18 AM
 To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 
 Subject: [flexcoders] How to compose a super tree item renderer using
 TreeItemRenderer and others
 
 
 
 Hi,
 I want a custom tree item renderer that consists of a basic
 TreeItemRenderer(to reuse its 
 tree node icons) and several other standard controls(they are also
 IListItemRenderer 
 implementors). Let's call it ComboTreeItemRenderer, and to simplify
the
 matters, assume 
 it is composed of a TreeItemRenderer and a Label.
 
 This is my first try:
 mx:Tree width=100% height=100% 
 id=tagTree 
 dataProvider={myTags} 
 change=handleTagSelection(event);
 mx:itemRenderer
 mx:Component
 mx:HBox
 mx:TreeItemRenderer
 /mx:TreeItemRenderer
 mx:Label text=[EMAIL PROTECTED]
 /mx:Label
 /mx:HBox
 /mx:Component
 /mx:itemRenderer
 /mx:Tree
 
 And the first error I met:
 Could not resolve mx:TreeItemRenderer to a component
implementation.
 
 I don't believe TreeItemRenderer can not be used in mxml coding, so I
 guess I was just not 
 coding in the right way. But what's the right way then?
 
 However, that's not really what I was stumped by, since I found that I
 could write a custom 
 component(named MyTreeItemRenderer) which extends
 TreeItemRenderer(nothing to 
 override, just to work around the could no resolve error), and it
 could be resolved of 
 course. So here is my second try:
 mx:Tree width=100% height=100% 
 id=tagTree 
 dataProvider={myTags} 
 change=handleTagSelection(event);
 mx:itemRenderer
 mx:Component
 mx:HBox
 mx:MyTreeItemRenderer
 /mx:MyTreeItemRenderer
 mx:Label text=[EMAIL PROTECTED]
 /mx:Label
 /mx:HBox
 /mx:Component
 /mx:itemRenderer
 /mx:Tree
 
 Now comes the really difficulties: I know I must assign values to some
 properties of 
 MyTreeItemRenderer using information carried by data and listData, but
 what properties 
 to assign value to? And what makes me even crazier is that I found
 neither listData and 
 data was set(observed by overriding set listData and set data
functions
 and find they were 
 never called).
 
 Looking forward to seeing helpful hints. Thanks in advance.