I have been trying unsuccessfully to set a HTTP break in my Flex 3 project. Obviously, I am totally clueless about programming and I don't have many references. When I try to export the project I receive parse errors for the result handler and var fault string. I am attaching a code snippet of where I have been placing the break.
<mx:HTTPService id="getData" url="http://www.myurl.com"
useProxy="false" method="GET" resultFormat="text" resultType="text"
result="resultHandler(event)" fault="faultHandler(event)">
private function resultHandler(e:ResultEvent):void {
trace(e.result);
}
private function resultHandler(e:FaultEvent):void {
var faultstring:String = event.fault.faultString;
Alert.show(faultstring);
}
<mx:request xmlns="">
<getTutorials>"true"</getTutorials>
</mx:request>
I think this may have to do with the PHP file and the type of data the Flex is looking for? Here is the first bit of the error I am receiving in the browser.
TypeError: Error #1034: Type Coercion failed: cannot convert "[{"id":"2","name":"Strapless Wedding Dress Tips","author":"Ramona Waters","rating":"0"},{"id":"3","name":"Coordinating Your Brides Maids","author":"Ericka Brown","rating":"0"}]" to mx.controls.Alert.
at DressBuilder2/resultHandler()
at DressBuilder2/__getData_result()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
Best Answer
Update: Cool, you've got your code compiled! Try with the following:
resultFormat=array
if you have anarray
of objects. Get this value in an array and loop over to see if you have can see the items. If this doesn't work try next tip.resultFormat
from the HTTPService tag (which is the same as if you had set it toobject
). See this.The functions in AS typically go inside a
<mx:Script>
tag. That's the first thing to fix. You will also have to import the definitions of the classes you are using. Have a look here:Try using this MXML file and let us know how far you got.