Skip navigation
Currently Being Moderated

Issue to convert a jsx Array to a AS3 Array

Sep 5, 2012 3:47 AM

Hi all,

 

I am calling a jsx code from within my extension to take advantage of the available xpath method in ExtendScript. I can then generate an array from the xpath result and send it back to the extension.

 

 

function jsXpath ( xmlString , xpathExpression )
{
          var res = XML ( xmlString ).xpath ( xpathExpression ), i = 0, n = res.length(), arr = [];
  
          for ( i = 0 ; i < n ; i++ )
          {
                    arr[ arr.length ]  = res[i];
          }
  
          return arr; 
}

 

My issue comes when I try to turn this jsx array into an AS3 array. EB then throws an error :

 

var arr:Array  = jsxInterface.jsXpath ( model.programmes.toXMLString() , xPathExpression ) //as Array;

Error #1034: Echec de la contrainte de type : conversion de flash.external::HostObject@2bfffe51 en Array impossible.

if I trace the result without coercion, I can see the expected result. I just can't turn it into a regular AS3 array

 

Any ideas ?

 

TIA Loic

 
Replies
  • Currently Being Moderated
    Sep 6, 2012 4:07 AM   in reply to Loic_aigon

    That's normal.

     

    JS Arrays are just fancy Objects. They are NOT ActionScript Array classes. They will function as normal JS Arrays if you leave them the Objects they are or you can copy the contents to a new ActionScript Array.

     

    Harbs

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points