Populating a flex 4.5 DataGrid using PHP and MySQL
Get the solution ↓↓↓Hey so I recently started working with Flash Builder 4.5 so I am facing a lot of silly problems while building a mobile application, specially when connecting my application to a back end server.
The thing I am working on currently should update a DataGrid and this data is retrieved from a MySQL Database.
This code displays the data clearly on the browser, however the datagrid is not updated. Instead it throws the following error.
TypeError: Error #1034: Type Coercion failed: cannot convert mx.utils::ObjectProxy@1e43bc1 to mx.collections.IList.
at views::connectPHPHomeView/userRequest_resultHandler()[C:\Documents and Settings\s4710935\Adobe Flash Builder 4.5\connectPHP\src\views\connectPHPHomeView.mxml:17]
at views::connectPHPHomeView/__userRequest_result()[C:\Documents and Settings\s4710935\Adobe Flash Builder 4.5\connectPHP\src\views\connectPHPHomeView.mxml:29]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:993]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at DirectHTTPMessageResponder/completeHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:451]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Can someone please guide me through this?
EDIT
Here is the PHP code:
<?php
//
And here is the MXML and AS3 part to my code: NOTE The sample XML result was added just for simplicity
{-code-3}
Answer
Answer
Solution:
In a spark DataGrid the dataProvider must implement an iList interface. It looks like you are returning XML and storing it in a generic object. A generic object does not support the IList interface.
Instead of binding the results of the remote call to the dataGrid's dataProvider, you should add a result handler to the HTTPService:
<s:HTTPService id="userRequest" url="{phpFile}"
method="GET" resultFormat="object" useProxy="false" result="onResult(event)">
Then cast your data in the result Handler to something that implements IList. I recommend an XMLListCollection in this case.
protected function onResult(event:ResultEvent):void{
var resultsXML : XML = event.results as XML
showTransactions_dg.dataProvider = new XMLListCollection(resultsXML);
}
This code was written in the browser and may not be perfect.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: xmlhttprequest error flutter
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.