Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Arrays are not bindable in AS 3; they don't dispatch/trigger data binding events themselves.</p> <p>If you are working with Flex, you can wrap your array in an <code>ArrayCollection</code> which <em>is</em> bindable, and manipulate the <code>ArrayCollection</code> instead of the <code>Array</code>, everything should automatically work as you hope.</p> <p>So, in practice:</p> <pre><code>var myAC:ArrayCollection = new ArrayCollection(myArray); var myDP = new DataProvider(myAC); myAC[0] = 'changing the array!'; // will be reflected in the dataProvider </code></pre> <p>Better yet, if you're passing that <code>DataProvider</code> instance to a Flex component, you can usually (almost always) just pass the <code>ArrayCollection</code> instead. But, you haven't shown enough context for me to be sure on this.</p> <p>Here's a few useful links:</p> <ul> <li><a href="http://livedocs.adobe.com/flex/3/html/help.html?content=databinding_4.html" rel="nofollow noreferrer">Binding to functions, Objects, and Array</a>s</li> <li><a href="http://livedocs.adobe.com/flex/3/langref/mx/collections/ArrayCollection.html" rel="nofollow noreferrer">ArrayCollection</a></li> </ul> <p><strong>Edit:</strong> My fault, I did indeed assume you were using Flex for the above. </p> <p>In plain old AS3, the principal is the same. The <code>Array</code> does not dispatch events, but the <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/" rel="nofollow noreferrer"><code>DataProvider</code></a> does. If you can make your changes <em>to the dataProvider itself</em> then you're good to go.</p> <p>The AS3 <code>DataProvider</code> class offers a bunch of methods for data manipulation, like <code>addItem</code>, <code>removeItem</code>, <code>replaceItem</code>, <code>replaceItemAt</code>, just for example.</p> <p>So, it basically comes down to what kind of changes you need to make to the source array. More often than not, you'll be able to do them via the <code>DataProvider</code>.</p>
 

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