You can also iterate over the arrayList.source.
> On Apr 11, 2019, at 5:16 AM, spiros <[email protected]> wrote:
>
> Hi Alex ,
>
> You have right the mx.collection.Arraylist and
> org.apache.flex.collections.ArrayList in flex didn’t iterate in flex.
> I already included the js code for the three cases ( it is on bottom of
> email).
> I don’t know if it helps but in one of my tests for the ArrayCollection I
> extend the class and add a method with name propertyNames (*1).
> in this case the iteration work fine.
>
> (*1)
> public function propertyNames():Array
> {
> var array:Array = new Array;
> for (var i:int= 0 ; i< length;i++)
> {
> array.push(this[i]);
> }
> return array
> }
>
>
>
> Best regards
>
>
> Spiros
>
>
>
>
>
> -----Original Message-----
> From: Alex Harui [mailto:[email protected]]
> Sent: Thursday, April 11, 2019 10:46 AM
> To: [email protected]
> Subject: Re: For each iteration in ArrayList and ArrayCollection
>
> Hi Spiros,
>
> Could you use for-each on an ArrayList in Flex? I didn't think it would
> work. I thought it only worked on ArrayCollection in Flex.
>
> What is the output JavaScript for your sample code when you use
> ArrayCollection? In Royale if you interate on XML, or a Proxy like
> ArrayCollection you have to make sure the compiler knows it is XML or a Proxy
> subclass. If it thinks items is an Object it will not generate the right
> code.
>
> HTH,
> -Alex
>
> On 4/10/19, 6:01 AM, "spiros" <[email protected]> wrote:
>
> Hi,
>
>
>
> I am trying to make an iteration using the for each. The property class is
> a simple class with two fields.
>
> I test the iteration with this classes :
>
>
>
>
>
> 1. org.apache.royale.collections.ArrayList error message: TypeError:
> propertyClass is undefined
>
> 2. mx.collections.ArrayList error message TypeError: propertyClass is
> undefined
>
> 3. mx.collections.ArrayCollection error message TypeError:
> foreachiter0_target.propertyNames is not a function
>
>
>
>
>
>
>
>
>
> the as3 code is:
>
>
>
> private function iteration():void
>
> {
>
> var object:Object = new Object;
>
> for each (var propertyClass:PropertyClass in items)
>
> {
>
> object[propertyClass.name] = propertyClass.index;
>
> }
>
> }
>
>
>
> Thanks in advanced
>
>
>
>
>
> Spiros
>
>
>
>
>
>
>
>
>
>
>
> ps: The js generated code for this 3 classes
>
>
>
> (1)
>
> /**
>
> * @private
>
> */
>
>
> com.novusnet.jsTests.ArrayCollectionIteration.prototype.com_novusnet_jsTests
> _ArrayCollectionIteration_iteration = function() {
>
> var /** @type {Object} */ object = new Object();
>
> var foreachiter0_target =
> this.com_novusnet_jsTests_ArrayCollectionIteration_items;
>
> for (var foreachiter0 in foreachiter0_target)
>
> {
>
> var propertyClass = foreachiter0_target[foreachiter0];
>
> {
>
> object[propertyClass.name] = propertyClass.index;
>
> }}
>
>
>
> };
>
> (2)
>
>
>
> /**
>
> * @private
>
> */
>
>
> com.novusnet.jsTests.ArrayCollectionIteration.prototype.com_novusnet_jsTests
> _ArrayCollectionIteration_iteration = function() {
>
> var /** @type {Object} */ object = new Object();
>
> var foreachiter0_target =
> this.com_novusnet_jsTests_ArrayCollectionIteration_items;
>
> for (var foreachiter0 in foreachiter0_target)
>
> {
>
> var propertyClass = foreachiter0_target[foreachiter0];
>
> {
>
> object[propertyClass.name] = propertyClass.index;
>
> }}
>
>
>
> };
>
>
>
> (3)
>
>
>
>
>
> /**
>
> * @private
>
> */
>
>
> com.novusnet.jsTests.ArrayCollectionIteration.prototype.com_novusnet_jsTests
> _ArrayCollectionIteration_iteration = function() {
>
> var /** @type {Object} */ object = new Object();
>
> var foreachiter0_target =
> this.com_novusnet_jsTests_ArrayCollectionIteration_items;
>
> for (var foreachiter0 in foreachiter0_target.propertyNames())
>
> {
>
> var propertyClass = foreachiter0_target.getProperty(foreachiter0);
>
> {
>
> object[propertyClass.name] = propertyClass.index;
>
> }}
>
>
>
> };
>
>
>
>
>
>
>
>