rcapilli
01-02-2007, 10:01 PM
I have a CFC which simply calls the DB and returns the results to the Flex app.
CFC:
<cfcomponent>
<cffunction name="runQuery" output="false" access="public" returntype="Query">
<cfquery name="qry_login" datasource="EWPROJ">
SELECT *
FROM ROBERTTEST
</cfquery>
<cfreturn qry_login>
</cffunction>
</cfcomponent>
Simple enough.......
Here is my Flex file...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp();">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var qry_result:ArrayCollection;
private function initApp():void //first thing to load
{
callCFC.runQuery()
}
private function resultHandler(event:ResultEvent):void
{
var qry_result:ArrayCollection = new ArrayCollection(); //New Array Object called p1
qry_result.source=event.result as Array;
trace(qry_result);
}
]]>
</mx:Script>
<mx:RemoteObject id="callCFC" destination="ColdFusion" source="CFIDE.samples.FlexToCFC.CFC.myCFC"
result="resultHandler(event)"
showBusyCursor="true" />
</mx:Application>
my problem is within the [resultHandler] I want to simply create a variable that will contain my results of the object I passed so I can trace it to the screen.... I know that the object is returning correctly, by tracing result.event. What am I doing wrong here, cause it shows nothing.
I'm guessing that my problem is that I am not putting the object into some sort of array or string where I can access it... How do I do this correctly? Thanks everyone.
CFC:
<cfcomponent>
<cffunction name="runQuery" output="false" access="public" returntype="Query">
<cfquery name="qry_login" datasource="EWPROJ">
SELECT *
FROM ROBERTTEST
</cfquery>
<cfreturn qry_login>
</cffunction>
</cfcomponent>
Simple enough.......
Here is my Flex file...
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp();">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var qry_result:ArrayCollection;
private function initApp():void //first thing to load
{
callCFC.runQuery()
}
private function resultHandler(event:ResultEvent):void
{
var qry_result:ArrayCollection = new ArrayCollection(); //New Array Object called p1
qry_result.source=event.result as Array;
trace(qry_result);
}
]]>
</mx:Script>
<mx:RemoteObject id="callCFC" destination="ColdFusion" source="CFIDE.samples.FlexToCFC.CFC.myCFC"
result="resultHandler(event)"
showBusyCursor="true" />
</mx:Application>
my problem is within the [resultHandler] I want to simply create a variable that will contain my results of the object I passed so I can trace it to the screen.... I know that the object is returning correctly, by tracing result.event. What am I doing wrong here, cause it shows nothing.
I'm guessing that my problem is that I am not putting the object into some sort of array or string where I can access it... How do I do this correctly? Thanks everyone.