It may work adding it to the rawChildren.

On Sat, Apr 19, 2008 at 9:28 PM, Derek Adams <[EMAIL PROTECTED]>
wrote:

>   I have a component that hands off rendering its graphics to a chain
> of pluggable renderers. The way I have it implemented right now, the
> chain is being executed in the overridden updateDisplayList function.
> The problem that I run into is when a renderer tries to add a child
> to the parent container, it generates an infinite loop due to
> addChild forcing an invalidateDisplayList(). Since I don't really
> need to interact with the text fields, I figured that drawing the
> bitmaps would be a usable solution. If you know a way to get around
> the infinite loop problem though, I would rather just be able to add
> components via the renderers. I know you would normally add children
> in the createChildren() function, but the renderers decide what gets
> added and the parent component has no knowledge of their internals.
>
> Thanks for your help!
> Derek
>
> --- In [email protected] <flexcomponents%40yahoogroups.com>,
> "Alex Harui" <[EMAIL PROTECTED]>
> wrote:
>
> >
> > Looks right to me. Those are the rules today. Why is having a
> child
> > TextField so bad? The Bitmaps can be expensive.
> >
> >
> >
> > ________________________________
> >
> > From: [email protected] <flexcomponents%40yahoogroups.com>
> > [mailto:[email protected]<flexcomponents%40yahoogroups.com>]
> On Behalf Of Derek Adams
> > Sent: Saturday, April 19, 2008 10:07 AM
> > To: [email protected] <flexcomponents%40yahoogroups.com>
> > Subject: [flexcomponents] Drawing text on a component without adding
> > subcomponents
> >
> >
> >
> > I have a custom component that needs to be able to paint a label on
> > its graphics context without adding a subcomponent for it. I
> figured
> > out a way to do it, but it seems like a hack. Does anybody know a
> > better way? Here is the code.
> >
> > // Create an auto-sized text field.
> > var label:IUITextField = new UITextField();
> > label.autoSize = TextFieldAutoSize.LEFT;
> > label.text = "String I want to render";
> >
> > // Draw the text into a bitmap.
> > var bm:BitmapData = new BitmapData(label.width, label.height);
> > bm.draw(label);
> >
> > // Draw bitmap on the graphics of the component.
> > comp.graphics.beginBitmapFill(bm, null, false);
> > comp.graphics.drawRect(0, 0, bm.width, bm.height);
> > comp.graphics.endFill();
> >
> > Any ideas?
> >
> > Thanks,
> > Derek
> >
>
>  
>

Reply via email to