Why not just have the setter for myCustomData simply set 'label' and
other properties rather than doing this in commitProperties()?

 

Gordon Smith

Adobe Flex SDK Team

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of thirtyfivemph
Sent: Friday, April 04, 2008 11:37 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Changing a property inside of commitProperties?

 

I'm subclassing FormItem to have the whole form item (its properties
and its child controls) driven by a single piece of data I specify in
a property I've added to my derived FormItem.

In my custom property's setter, I store the custom data and call
"invalidateProperties". I then do this:

override protected function commitProperties():void
{
super.commitProperties();

if (myCustomData)
{
label = myCustomData.someCustomString;
}
}

The problem is that the FormItem doesn't display correctly... the
label gets truncated to zero width because its not getting re-measured
when I set the label.

After some debugging, I found that the problem is that when I set the
label property, it internally calls invalidateProperties, which sets a
flag to "true" indicating that properties are invalid and need to be
validated at the next opportunity. Unfortunately, since I'm inside of
the commitProperties method I'm in the middle of a validation. At the
end of that validation, the "properties are invalid" flag gets reset,
with the result being that any calls to invalidateProperties *during*
commitProperties are *ignored*! Yikes!

How do I work around this? I could do a
callLater(invalidateProperties), but then code later during the same
frame that calls validateNow() on my form (which is necessary for some
effects/measuring I'm doing) wouldn't work because callLater won't
happen until the *next* frame.

Perhaps the validation code should reset the validate flag *before*
calling commit properties, so that any invalidations during
commitProperties are properly recorded?

Troy.

 

Reply via email to