Menu

#15 AS3 error when serializing arrays

open
nobody
None
7
2008-07-01
2008-05-13
No

When serializing an array it serializes as an Object, this is due to the order in which the code gets executed.

Checking whether something is an object happens before checking whether it is an array, and since all arrays are objects, the code for arrays will never be executed.

This can be prevented by simply switching the execution order in the code.

Discussion

  • Gerrit Bertier

    Gerrit Bertier - 2008-07-01
    • priority: 5 --> 7
     
  • Nobody/Anonymous

    Logged In: NO

    As is stated here, Arrays are indeed typed as objects when using typeof
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/operators.html#typeof

    I changed the execution order as stated above and this seems to work, however I don't understand how this is possible as the typeof on an array returns object. So how could it ever execute the if array part?

     
  • Gerrit Bertier

    Gerrit Bertier - 2008-08-11

    Logged In: YES
    user_id=2085810
    Originator: YES

    When using the 'is' keyword, I'm not to sure typeof value is really used, I'm thinking it's more like checking whether something has all the necessary properties and methods to be of the desired type.

    So an array IS an object, but an object IS NOT necessarely an array, hence you needed to switch the order :)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.