Yes, you should be using invalidation. The
typical pattern for doing this is as follows:
private var
_buttonLabel:String = "";
private var buttonLabelChanged:Boolean
= false;
public function get
buttonLabel():String
{
return
_buttonLabel;
}
public function set
buttonLabel(value:String):void
{
_buttonLabel = value;
buttonLabelChanged = true;
invalidateProperties();
}
override protected
function commitProperties():void
{
super.commitPropertie();
if (buttonLabelChanged)
{
myButton.label = _buttonLabel;
buttonLabelChanged = false;
}
}
You can find many examples of thsi pattern
in the framework source code.
- Gordon
From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Sergey Kovalyov
Sent: Friday, September 29, 2006
9:18 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Setting
properties to children technique
Hi All!
Imagine, I have a component based on VBox and Button child myButton
inside it. I have a property (getter/setter) in component buttonLabel:
public function get buttonLabel() : String {
return myButton.label;
}
public function set buttonLabel(buttonLabel : String) : void {
myButton.label = buttonLabel;
}
Sure, I get null pointer exception, while instantiating component and
setting its buttonLabel property, because myButton is not created yet:
"My Label" />
Probably, some invalidation must be used. invalidateProperties() >
commitProperties(), true? Are there any other ideas?
Sergey.
__._,_.___
--
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
Software development tool
Software development
Software development services
Home design software
Software development company
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group
|
Yahoo! Groups Terms of Use
|
Unsubscribe
__,_._,___