1 Reply Latest reply on Jun 9, 2007 10:54 PM by chris.huston.t10

    How to determine size of result object?

      How can one determine the size of the result object? I need to know how many times to iterate through a result object.

      Alternatively, would like to use for...each but doesn't work for me -- only iterates through once and stops. Here's my code:

      for each ( evt.result.root.offeringRoot in evt.result.root ){
      myArray.addItem( {offeringName:evt.result.root.offeringRoot.offeringName, offeringNumber:evt.result.root.offeringRoot.offeringNumber, offeringID:evt.result.root.offeringRoot.offeringID, offeringType:evt.result.root.offeringRoot.offeringType, offeringDate:evt.result.root.offeringRoot.offeringDate, offeringTime:evt.result.root.offeringRoot.offeringTime} );

      The XML coming back in the result object (as type Object) is:
      <offeringName>Math 101</offeringName>
      <offeringType>Live Class</offeringType>
      <offeringTime>8:00 AM</offeringTime>

      As always thanks!
        • 1. Re: How to determine size of result object?
          chris.huston.t10 Level 3
          You can get the size by : evt.result.root.offeringRoot.length;

          For your loop you could do something like this:

          for each (var item:Object in evt.result.root.offeringRoot) {

          But it doesn't seem like you need to loop through your result since it is already an XML object and can be bound directly to a variable such as myArray like this:

          var myArray:ArrayCollection = evt.result.root.offeringRoot;