Flex组件have 4 methods in protected
namespace which should be overridden to solve different tasks:
createChildren()
- 调用一个时间来创建并添加子。
measure()
呼吁在布局计算组件大小的过程中。
updateDisplayList()
具有实分量未缩放的宽度和高度作为参数。很明显,这种方法很方便儿童的定位。
commitProperties()
是我建议你重写的方法,以便应用不需要使用组件大小的属性值。
所以在你的情况下,它可以是updateDisplayList()
或commitProperties()
。我建议你下面的代码片段:
private var myproperty1Dirty:Boolean;
private var _myproperty1:String;
public function set myproperty1(value:String):void
{
if (_myproperty1 == value)
return;
_myproperty1 = value;
myproperty1Dirty = true;
// Postponed cumulative call of updateDisplayList() to place elements
invalidateDisplayList();
}
private var myproperty2Dirty:Boolean;
private var _myproperty2:String;
public function set myproperty2(value:String):void
{
if (_myproperty2 == value)
return;
_myproperty2 = value;
myproperty2Dirty = true;
// Postponed cumulative call of commitProperties() to apply property value
invalidatePropertues();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (myproperty1Dirty)
{
// Perform children placing which depends on myproperty1 changes
myproperty1Dirty = false;
}
}
override protected function commitProperties():void
{
super.commitProperties();
if (myproperty2Dirty)
{
// Apply changes of myproperty2
myproperty2Dirty = false;
}
}
希望这有助于!
它帮助我解决:)非常感谢你的谜语。 :) – 2011-05-28 19:31:29
不客气! – Constantiner 2011-05-28 19:31:57