Yeah thats the way I've done it previously. I thought that this way would
cut out on some additional computation.



On Tue, Aug 31, 2010 at 6:04 PM, valdhor <valdhorli...@embarqmail.com>wrote:

>
>
> That seems overly complicated to me. What I would try is create two custom
> components then instantiate the appropriate one based on the data and add it
> in the updateDisplayList method.
>
>
> --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, Wesley
> Acheson <wesley.ache...@...> wrote:
> >
> > Since nobody has replied I'm continueing to try this. I currently think I
> > may need to override all methods in UI component.
> >
> >
> > Is it clear what I'm trying to do?
> >
> > Is this the wrong way of doing it?
> >
> > I think its probably lighter than wrapping to components in a fully
> fledged
> > UI component?
> > *
> > Some Thoughts*
> >
> > Also a comment on ListItemRenderer, theres an awful lot of methods that
> need
> > to be implemented to make this work. I doubt all of them are used in a
> List
> > Senario. Even implementing them all theres still a dependency on
> > DisplayObject (who's methods seem to be implemented). It does feel to me
> > like the architecture seems a bit off. I mean if all of those methods are
> > implemented why is there still a dependency on DisplayObject.
> >
> > Its not just enough to implement IListRenderer which seems to defeat the
> > purpose of an interace
> >
> > On Wed, Aug 18, 2010 at 11:42 PM, Wesley Acheson
> > <wesley.ache...@...>wrote:
>
> >
> > > *Disclaimer:* This is a cross post with Stack Overflow. I know at least
> > > one person on this list saw it there.
> > > http://stackoverflow.com/questions/3507313/flex-switch-item-renderer
> > >
> > > Hi
> > >
> > > I was wondering if anyone had any luck with the following senario in
> flex.
> > >
> > > I'd like to be able to have a custom item renderer which delegates to
> > > another renderer inside.
> > >
> > > The reason for this would be in a datagrid for instance displaying a
> > > checkbox if the dataprovider for the row had a boolean value. Using the
> > > default item renderer when the value was a non boolean.
> > >
> > > Basically I was hoping to use a proxy object (though not necessarily
> the
> > > proxy class) so that I could a renderer which delegated all of its
> > > responsibilties to a sub renderer.
> > >
> > > Hard to explain.
> > >
> > > *Edit 1*
> > >
> > > I think the following gives a clearer idea of what I had in mind. This
> is
> > > only knocked up quickly for the purpose of showing the idea.
> > >
> > > *SwitchingRenderer.as*
> > >
> > > package com.example
> > > {
> > > import mx.controls.CheckBox;
> > >
> > > import mx.controls.dataGridClasses.DataGridItemRenderer;
> > >
> > > import mx.controls.listClasses.BaseListData;
> > >
> > > import mx.controls.listClasses.IDropInListItemRenderer;
> > >
> > > import mx.core.IDataRenderer;
> > >
> > > import mx.core.UIComponent;
> > >
> > > public class SwitchingRenderer extends UIComponent implements
> IDataRenderer, IDropInListItemRenderer
> > >
> > > {
> > > private var checkboxRenderer:CheckBox;
> > >
> > > private var defaultRenderer:DataGridItemRenderer;
> > >
> > > private var currentRenderer:IDataRenderer;
> > >
> > > public function SwitchingRenderer()
> > >
> > > {
> > > this.checkboxRenderer = new CheckBox();
> > >
> > > this.defaultRenderer = new DataGridItemRenderer();
> > >
> > > this.currentRenderer = defaultRenderer();
> > >
> > > super();
> > > }
> > >
> > > public function get data():Object
> > >
> > > {
> > > //If the data for this cell is a boolean
> > > // currentRender = checkBoxRenderer
> > >
> > > // otherwise
> > > // currentRenderer = defaultRenderer
> > > }
> > >
> > > public function set data(value:Object):void
> > >
> > > {
> > > currentRenderer.data = value;
> > >
> > > }
> > >
> > > public function get listData():BaseListData
> > >
> > > {
> > > return currentRenderer.listData;
> > >
> > > }
> > >
> > > public function set listData(value:BaseListData):void
> > >
> > > {
> > > currentRenderer.listData = value;
> > >
> > > }
> > >
> > >
> > >
> > > }
> > > }
> > >
> > >
> > >
> >
>
>  
>

Reply via email to