0

I am building a Flex Mobile Application and I keep getting this error:

TypeError: Error #1034: Type Coercion failed: cannot convert mx.collections::ArrayCollection@ba39581 to Array.

It says that the error is occurring here (at the ArrayCollection Part):

<s:List id="invites" x="5" y="295" width="310" change="rowSelected(event)">
        <s:dataProvider>
            <s:ArrayCollection source="{getInvites.lastResult.Invites.EventTitle}"/>
        </s:dataProvider>
    </s:List>

The "getInvites" HTTPService call:

<s:HTTPService id="getInvites" result="getInvitesResult(event)" method="POST" url="http://localhost/invite.php" useProxy="false">
            <s:request xmlns="">
                <method>GET_INVITES</method>
                <userID>{my_id.text}</userID>
            </s:request>
        </s:HTTPService>

I have no idea why this error is occurring and I have been trying to figure it out for 2 hours. Any help is highly appreciated.

Also the "invite.php" file can be accessed, and is working correctly.

Thanks, Jacob

RMK-Jacob
  • 209
  • 1
  • 4
  • 15

1 Answers1

0

Most likely your remote Service is returning an array at getInvites.lastResult.Invites.EventTitle which is not the same as an ArrayCollection and can't be converted "on the fly".

You can try this:

<s:List id="invites" x="5" y="295" width="310" change="rowSelected(event)">
        <s:dataProvider>
            <s:ArrayCollection source="{new ArrayCollection(getInvites.lastResult.Invites.EventTitle)}"/>
        </s:dataProvider>
    </s:List>

But, honestly I strongly suggest you add a proper result handler to your HTTPService call and process the results in that.

JeffryHouser
  • 39,401
  • 4
  • 38
  • 59