Workaround for Error #1034: Type Coercion failed: cannot convert mx.utils

When I gave my first flexool build to Zoltan, he reported 2 erros and one of them was “TypeError: Error #1034: Type Coercion failed: cannot convert mx.utils::ObjectProxy@6380a19 to mx.collections.ArrayCollection”.

Not a familiar one for me. So I checked the engine I sent him on my machine. It was working fine without error. the i googled and found the reason behind this.  It happens when there is only 1 single node in the xml flex is trying to load. So it is returned as an ObjectProxy instead of an Array and the error pops up. Perhaps a bug with flex.

See the solution here: http://forum.sephiroth.it/showthread.php?p=32751

It solved my problem. thanks tekati

Advertisements

7 responses to “Workaround for Error #1034: Type Coercion failed: cannot convert mx.utils

  1. Thank you! This solved my issue. I was stuck on this all day, it never occurred to me an array with one parent node wouldn’t be treated as an array.

  2. Bravo Mohit & Tetaki ..Bravo !!! [:)]

  3. Jose D. Montero

    Flex Error #1034

    By Jose D. Montero
    Date Dec. 11, 2009

    TypeError: Error #1034: Type Coercion failed: cannot convert mx.utils::ObjectProxy@6380a19 to mx.collections.ArrayCollection”.

    It is correct the answer. .

    Example:
    I got the errors when I had:

    Where variable gasBalancesList was defined as ArrayCollection and the gasBalancesData.xml file was the following:

    1001
    Ga for NW Pipe Line Location1
    789001
    active
    50521
    12/11/2009

    Solution: Add at least one more record. If there is only one then it treats result as an ObjectProxy. If two or more records then it forces result to be Array Collection.

  4. Thanks a lot. Solve my problem i was stuck for a long time =).

  5. kanu kukreja

    I am facing the same problem, but still the solution doesn’t resolved my issue.
    Can you please tell me how to handle this when i never know whether i’ll get one node in XML or more.As if i follow this then it resolves the issue if there’s just one node but same time throws error if its more than one.

  6. import mx.utils.ArrayUtil;

    if (event.result.rows.row is ArrayCollection) {
    theArray = event.result.entries.day;
    } else if (event.result.rows.row is ObjectProxy) {
    theArray = new ArrayCollection(ArrayUtil.toArray(event.result.rows.row));
    }

    this work for me :D, thank you and tekati 😀 !!!!

  7. don’t forget to import….
    import mx.utils.ObjectUtil;
    import mx.utils.ObjectProxy;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s