AFAIK, createChildren() may be called more then once during the app life cycle, so it's neccessary to check the existence of the children before creating it.


Jeremy.



On 8/3/06, astgtciv <[EMAIL PROTECTED]> wrote:

flex2_createandextendcomponents.pdf is careful to repeate that if you are
extending a component, in your createChildren() method, test for existence
of children before creating them to allow subclasses to "create a different
child instead"(e.g., page 168).

However, the children in that (and every other) example come from private
variables in the component with no getters/setters, so the subclass would
not be able to access them to create a "different child instead"... am I
missing something important?

Example:

public class ModalText extends UIComponent {

...

private var text_mc:TextArea;

private var mode_mc:Button;

...

/*** Implement the createChildren() method. ***/

// Test for the existence of the children before creating them.

// This is optional, but do this so a subclass can create a

// different child instead.

override protected function createChildren():void {

super.createChildren();

// Create and initialize the TextArea control.

if (!text_mc) {

text_mc = new TextArea();

...

addChild(text_mc);

}

// Create and initialize the Button control.

if (!mode_mc) {

mode_mc = new Button();

....

}


__._,_.___

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





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to