First you need to change your mx:RemoteObject to
<mx:RemoteObject id="jobSvc" destination="ColdFusion" source="path.to.cfc"
showBusyCursor="true">
<mx:method name="GetJob" result="getJobResult(event)"/>
</mx:RemoteObject>
Then add a result handler:
private function getJobResult(event:Object):void
{
jobNameCB.dataProvider = event.result as ArrayCollection;
}
Steve
On 3/2/07, April <[EMAIL PROTECTED]> wrote:
Thank you very much for this response. I think this is still a bit over
my head at this point
(I have only done tutorials, and none of the tutorials interact with a
database the way I will
be) but I will give it a stab and see what I can do with it.
I was looking at an article on Ben Forta's blog (
http://www.forta.com/blog/index.cfm?
mode=e&entry=1786) and following his example I did this... only it doesn't
work:
I'm very very new to Flash and we are using ColdFusion but are not using
Flex Data
Services. I've been trying to figure out how to populate a combobox from a
database and
I'm just not having any luck.
My project is called "PreTraffic". I have my main file as "JobSearch.mxml"
and a folder
under the root named "cfc" with a file called "job.cfc".
job.cfc contains the following code:
<cfcomponent>
<!--- Get jobs --->
<cffunction name="GetJob" access="remote" returntype="query"
output="false">
<cfset var job="">
<cfset var results="">
<cfquery datasource="discsdev" name="job">
SELECT job_id, job_title
FROM job
WHERE status = 'O'
ORDER BY job_title
</cfquery>
<cfquery dbtype="query" name="results">
SELECT job_title AS label, job_id AS data
FROM job
ORDER BY label
</cfquery>
<cfreturn results>
</cffunction>
</cfcomponent>
And JobSearch.mxml has the following code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns="*"
layout="absolute"
backgroundGradientColors="[#ffffff, #d0d0d0]"
creationComplete="InitApp()">
<mx:Style source="style.css" />
<mx:Script>
<![CDATA[
public function InitApp():void {
jobSvc.GetJob();
}
]]>
</mx:Script>
<!-- ColdFusion CFC (via AMF) -->
<mx:RemoteObject id="jobSvc" destination="PreTraffic"
showBusyCursor="true" />
<mx:VBox label="Job History" width="100%" height="100%" x="10" y="92">
<mx:Label text="Search jobs by"/>
<mx:Form label="Task" width="100%">
<mx:FormItem label="Job Name:">
<mx:ComboBox id="jobNameCB" dataProvider="{jobSvc.GetJob.results}"></
mx:ComboBox>
</mx:FormItem>
</mx:Form>
<mx:HBox>
<mx:Button label="Search"/>
<mx:Button label="Clear"/>
</mx:HBox>
</mx:VBox>
</mx:Application>
My Compiler thingy points to:
-services "/Volumes/flexwwwroot/WEB-INF/flex/job-services-config.xml"
-locale en_US
and job-services-config.xml contains the following code:
<destination id="PreTraffic">
<channels>
<channel ref="my-cfamf"/>
</channels>
<properties>
<source>flex.pretraffic.cfc.job</source>
<lowercase-keys>true</lowercase-keys>
</properties>
</destination>
Well, when I run the app... the combobox is not populated... Can anyone
help with what
I've done wrong?
Thanks!