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

----- Original Message ----- 
From: "Sergey Kovalyov" <[EMAIL PROTECTED]>
To: <flexcoders@yahoogroups.com>
Sent: Wednesday, July 19, 2006 10:01 AM
Subject: [flexcoders] addChild() in constructor?


As far as I understand, now I can work with superclass view directly
from constructor of inherited class after super() call?

public class A extends Box {

function A() {
addChild(new TextInput()); // causes exception
}

}

public class B extends A {

function B() {
super();
addChild(new TextInput()); // works correctly
}

}

Is this behaviour is okay and could be used by developers?

Sergey.



--
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 --------------------~--> 
See what's inside the new Yahoo! Groups email.
http://us.click.yahoo.com/2pRQfA/bOaOAA/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