He wrote that code before the developer's summit is my guess.  Ely told us 
specificlly not to add creation stuff in the constructors, only adding event 
listeners.  The reason for this is the overhead that the constructor adds 
when instantiating a class.  You can defer creation of children if need be 
if it's in a createChildren; but if it's in a constructor, you have no 
choice; doing var a:A = new A(); suddenly has a lot of overhead.

Not sure why you're getting an exception, though, sorry.

----- Original Message ----- 
From: "Sergey Kovalyov" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, July 19, 2006 10:31 AM
Subject: Re: [flexcoders] addChild() in constructor?


Actually, I found this approach in IPE Controls by Ely Greenfield
(http://demo.quietlyscheming.com/IPE/). There are classes like this
there:

package qs.ipeControls
{
import qs.ipeControls.classes.IPESlider;
import mx.controls.HSlider;

public class IPEHSlider extends IPESlider
{
public function IPEHSlider():void
{
super();
editableControl = new HSlider();
}
}
}

In superclass IPESlider, editableControl setter is defined this way:

protected function set editableControl(value:UIComponent):void
{
if(_editableControl != null)
removeChild(_editableControl);
_editableControl = value;
_editableControl.styleName = this;
addChild(_editableControl);
_editableControl.visible = _editable;
facadeEvents(_editableControl,"dataChange");

_editableControl.addEventListener(FocusEvent.FOCUS_OUT,commitOnBlurHandler);

invalidateDisplayList();
}

And it works... What's wrong?

On 7/19/06, JesterXL <[EMAIL PROTECTED]> wrote:
> You're not supposed to create and add children in the constructor.  Do it 
> in
> createChildren, like this:
>
> protected override function createChildren():void
> {
>     super.createChildren();
>
>     if ( my_txt == null)
>     {
>         my_txt = new TextInput();
>         addChild ( my_txt );
>     }
> }
>
> More info here:
> http://www.flex.org/ACDS/BuildingAFlexComponent.pdf



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Groups gets a make over. See the new email design.
http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to