Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Good question. Let's assume your code looks something like this:</p> <pre><code>public function get dataArr():Array { return _dataArr; } public function set dataArr(val:Array):void { dispatchEvent(new Event(Event.CHANGE)); _dataArr = val; } </code></pre> <p>Now let's assume you have an object, say <code>model</code> that contains these functions. Remember that <code>get</code> and <code>set</code> functions are basically syntactical sugar. So even though something may look like a simple assignment, it's still a function call.</p> <pre><code>// like calling some function model.setDataArr([1, 2, 3, 4, 5]); // so event gets dispatched model.dataArr = [1, 2, 3, 4, 5]; // liek calling some function model.getDataArr().push(6); // so setter never gets called and thus event is not dispatched. model.dataArr.push(6); </code></pre> <p>So in short, when you do something like <code>shift</code> or <code>push</code> or whatever, the event won't get dispatched. <code>model.dataArr</code> uses the get function to return your array, and then you're calling methods on that returned array. As the set function never gets called, the event never gets dispatched.</p> <p>You can see similar scenarios throughout the AS3 API. Take <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#transform" rel="nofollow">DisplayObject#transform</a> for example. When you just do something like <code>dispObj.transform.matrix.tx += 10</code> the internal set function is never called and there is no affect. So you have to actually assign a new transform <code>dispObj.transform = someTransform</code> for the set function to get called. The same applies to you - you have to actually assign some array for the set function to be called and your event dispatched.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload