
697
DEVELOPING
COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Las
t
upda
te
d 8/5/2010
3
Define a search function that sends user data to the Flash Remoting service. See “
Submitting user data to the Flash
Remoting service
” on page 697.
4
Define a result function that captures the results returned from the Flash Remoting service. See “
Capturing Flash
Remoting service results
” on page 698.
5
Ensure that the SWF movie has established a connection to the Flash Remoting service. See “
Checking for a Flash
Remoting service connection
” on page 699.
Writing the server-side ActionScript function
The example here creates a search function that performs a simple search operation against a ColdFusion data source.
This function accepts two arguments, firstName and lastName, and returns any records found that match these
arguments.
Create a server-side ActionScript function
❖
Create a server-side ActionScript file that contains the following code:
//search takes firstName lastName arguments
function search(firstName, lastName)
{
searchdata = CF.query({datasource: "bigDSN",
sql:"SELECT * from personnel WHERE fname = firstName AND lname = lastName"{);
if (searchdata)
return searchdata;
else
return null;
}
Creating the SWF movie interface
The SWF movie interface example here consists of one frame with a variety of text boxes and a submit button.
1
In the Flash authoring environment, create a Flash source file, and save it as pDirectory.fla.
2
Create two input text boxes. Name one text box variable
lastName
and the other
firstName
.
3
Create a dynamic text box, and name its variable
status
.
4
Insert a list box component, and name it
dataView
.
5
Insert a push-button component.
6
Save your work.
Submitting user data to the Flash Remoting service
To send data to server-side ActionScript, create a function that passes the data from the SWF movie to server-side
ActionScript. The
search
function, applied at the frame level, collects the user-entered data from the firstName and
lastName text boxes and passes the data as function arguments to the directoryService object, which is created when
the SWF movie connects to the Flash Remoting service. For more information, see “
Checking for a Flash Remoting
service connection
” on page 699.
The following is a Flash ActionScript example:
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...