I have tried this and it is always trapped as 'error'. the Boolean method doesn't make any sense to me, but thats just me :-)
The best thing that really worked (and is always working and easy to understand) is to get my cffuction return a numeric value instead, the traditional 0 or 1. I then just compare (event.result ==1) and it really works! is there any danger of using that instead of the boolean? thanks, George On 10/5/07, Brian Holmes <[EMAIL PROTECTED]> wrote: > > Boolean(event.result) > > Did you try (event.result as Boolean) > > ------------------------------ > *From:* [email protected] [mailto:[EMAIL PROTECTED] *On > Behalf Of *George Georgiou > *Sent:* Thursday, October 04, 2007 3:24 PM > *To:* [email protected] > *Subject:* [flexcoders] Flex always returns true, how is this possible? > > > > Hi guys, > > I have this very strange problem: here's my code for those that are > willing to help: > > > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="absolute"> > > <mx:Script> > <![CDATA[ > import mx.rpc.events.ResultEvent; > import mx.controls.Alert; > > private function submitForm():void { > var params:Object = new Object(); > params.firstName = firstName.text; > params.lastName = lastName.text; > myService.insertArtist(params); > } > > private function myResultHandler(event:ResultEvent):void { > if (Boolean(event.result) == true) { > Alert.show("New Artist added!!"); > } else { > Alert.show("Error"); > } > } > > ]]> > </mx:Script> > > > <mx:RemoteObject id="myService" destination="ColdFusion" source=" > RemoteObject.cfc.queries" > result="myResultHandler(event)" showBusyCursor="true" /> > > > <mx:Form> > <mx:FormItem> > <mx:Label text="First Name" /> > <mx:TextInput id="firstName" /> > </mx:FormItem> > <mx:FormItem> > <mx:Label text="Last Name" /> > <mx:TextInput id="lastName" /> > </mx:FormItem> > <mx:FormItem> > <mx:Button label="Submit" click="submitForm();" /> > </mx:FormItem> > </mx:Form> > > </mx:Application> > > > > and my simple CFC contains.... > > <cffunction name="insertArtist" access="remote" returntype="boolean"> > <cfargument name="firstName" type="string"> > <cfargument name="lastName" type="string"> > > <cfset success = true> > > <cftry> > <cfquery name="qInsertArtist" datasource="flexdata"> > insert into tbl_test (firstName,lastName) > values ('#arguments.firstName#','#arguments.lastName#') > </cfquery> > <cfcatch type="database"> > <cfset success = false> > </cfcatch> > </cftry> > > <cfreturn success> > </cffunction> > > > > Notice that even if I enter to the end of my cffunction the <cfreturn > false>, my myResultHandler always returns a "New Artist Added" (meaning that > it always report true). The tbl_test table does not even exist!!! How is it > possible to get a 'True' message from Flex? is that kind of a bug? Or am I > doing something wrong? I used to have a similar problem when using an > HTTPService. > > Thanks for your help, really helpful :) > > George > > > > > > > ------------------------------ > *** > The information in this e-mail is confidential and intended solely for the > individual or entity to whom it is addressed. If you have received this > e-mail in error please notify the sender by return e-mail delete this e-mail > and refrain from any disclosure or action based on the information. > *** > > >

