Actionscript 3 ActionScript3.0:琐碎的setter调用getter三次。为什么?

Actionscript 3 ActionScript3.0:琐碎的setter调用getter三次。为什么?,actionscript-3,flash,properties,setter,getter,Actionscript 3,Flash,Properties,Setter,Getter,以下面的代码为例: private var m_iWidth:int; [Bindable] public function get width():int { Alert.show("getter"); return m_iWidth; } private function set width(pValue:int):void { Alert.show("setter"); m_iWidth = pValue; } private function someF

以下面的代码为例:

private var m_iWidth:int;
[Bindable]
public function get width():int
{
    Alert.show("getter");
    return m_iWidth;
}
private function set width(pValue:int):void
{
    Alert.show("setter");
    m_iWidth = pValue;
}

private function someFunction(pWidth:int):void
{
    width = pWidth;
}
width的输出=pWidth是:

getter
setter
getter
getter
请解释一下。谢谢。

1)设置属性时,代码首先调用getter以查看值是否不同。如果相同,则不调用setter(解释第一个get/set对)


2) 如果属性是绑定的,在设置之后,任何访问都将调用getter(解释最后两个getter调用)

width属性是可绑定的-您有绑定到它的东西吗?这可以解释最近两次getter电话。设置属性时,代码首先调用getter以查看值是否不同——如果相同,则不调用setter。“至少,我相信我观察到了这点。”比尔特纳:谢谢,我想就是这样。将您的评论移至答案。