Let's refer to the listing of the method "validateProperties" 开发者_运维问答from mx.core.UIComponent class from Flex 3 (Flex 4) SDK
public function validateProperties():void
{
if (invalidatePropertiesFlag)
{
commitProperties();
invalidatePropertiesFlag = false;
}
}
My question is:
Why dirty flag invalidatePropertiesFlag is reset after commitProperties call, but not before this call?
I speculate this is because:
1) it is just a matter of life to put dirty flag at the end of IF block;
2) If code within commitProperties raises RTE, we still will have a chance to execute the code in commitProperties during playing next frame in Flash Player and this time maybe the code will not throw RTE.
The reason why do I ask this question is the following fact:
If the code within commitProperties will try to invalidate some another UIComponent's property by using dirty flag and invalidateProperties invalidation call, then this invalidation call will not be added to mx.managers.LayoutManager.invalidatePropertiesQueue, because dirty flag invalidatePropertiesFlag was not yet reset before commitProperties call.
According execution flow it looks logically "to mark as not changed" (reset flag) only after processing and setting state to valid condition finished. If some other property should be invalidated using the same flag - then there should be separate flags to do this.
Update: Sorry for misunderstanding the real issue. I must agree to you here that in case of invalidatePropertiesFlag it should be set to false before calling commitProperties. Meanwhile you ought to call invalidation methods via something like callLater()
.
精彩评论