Hi,
I am reading
org.apache.flex.collections.ArrayList.as
I am confused about this private property:
/**
* @private
* Indicates if events should be dispatched.
* calls to enableEvents() and disableEvents() effect the value when
== 0
* events should be dispatched.
*/
private var _dispatchEvents:int = 0;
It is changed in following 2 private methods only:
/**
* Disables event dispatch for this list.
* To re-enable events call enableEvents(), enableEvents() must be
called
* a matching number of times as disableEvents().
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
private function disableEvents():void
{
_dispatchEvents--;
}
/**
* Enables event dispatch for this list.
*
* @langversion 3.0
* @playerversion Flash 9
* @playerversion AIR 1.1
* @productversion Flex 3
*/
private function enableEvents():void
{
_dispatchEvents++;
if (_dispatchEvents > 0)
_dispatchEvents = 0;
}
And these 2 methods only get called in constructor:
public function ArrayList(source:Array = null)
{
super();
disableEvents();
this.source = source;
enableEvents();
}
I think this private property can be simplified as:
private var _constructed:Boolean = false;
and:
public function ArrayList(source:Array = null)
{
super();
this.source = source;
_constructed = true;
}
Could anyone help me see the difference plz??
Best,
-Gary