
616
DEVELOPING
COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Las
t
upda
te
d 8/5/2010
Using Flash with CFCs
CFCs require little modification to work with a SWF application. The tag
cffunction
tag names the method and
contains the CFML logic, the
cfargument
tag names the arguments, and the cfreturn tag returns the result to the SWF
application. The name of the CFC file (*.cfc) translates to the service name in ActionScript.
Note:
For CFC methods to communicate with SWF applications, set the
cffunction
tag’s
access
attribute to
remote
.
The following example replicates the
helloWorld
function that was previously implemented as a ColdFusion page.
For more information, see “
Using the Flash Remoting service with ColdFusion pages
” on page 611.
Create a CFC that interacts with a SWF application
1
Create a CFC and save it as flashComponent.cfc in the helloExamples directory.
2
Modify the code in flashComponent.cfc so that it appears as follows:
<cfcomponent name="flashComponent">
<cffunction name="helloWorld" access="remote" returnType="Struct">
<cfset tempStruct = StructNew()>
<cfset tempStruct.timeVar = DateFormat(Now ())>
<cfset tempStruct.helloMessage = "Hello World">
<cfreturn tempStruct>
</cffunction>
</cfcomponent>
In this example, the
helloWorld
function is created. The
cfreturn
tag returns the result to the SWF application.
3
Save the file.
The
helloWorld
service function is now available through the
flashComponent
service to ActionScript. The
following ActionScript example calls this function:
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...