Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Flex Developer Center /

Set up and build your first Flex and ColdFusion application – Part 3: Use ColdFusion and Flash Builder 4 to create an application

by Trilemetry

Trilemetry
  • Trilemetry, Inc.

Content

  • Create a Flash Builder project
  • Connect to the ColdFusion server
  • Introspect and import a CFC
  • Create a simple employee data display

Created

22 March 2010

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
CFC ColdFusion data services Flex

Requirements

Prerequisite knowledge

This tutorial is intended for:

  • Developers who are exploring tutorials in the Flex and ColdFusion mini learning center that are based on the Fictitious Sales Planner example.
  • Experienced ColdFusion developers without previous Adobe Flex framework or Adobe Flash Builder 4 experience.
  • ColdFusion developers who are familiar with ColdFusion components.

User level

All

Required products

  • ColdFusion (Download trial)
  • Flash Builder (Download trial)

Sample files

  • f4cf_fictitious_db.zip (75 KB)
  • f4cf_generated_cfcs.zip (4 KB)

In Part 1, you learned how to set up a ColdFusion data source and Flash Builder project. In Part 2, which is optional, you generated the ColdFusion components (CFCs) using ColdFusion Builder. In this section, you will set up a Flash Builder data service project with ColdFusion for use with the Fictitious Sales Planner sample application.

Create a Flash Builder project

A Flash Builder project is similar to a Dreamweaver site. You create a project to store and organize your code files. Follow these steps to create a Flash Builder project:

  1. Open Flash Builder 4.

    Note: We assume that you are working with the standalone (not the plug-in) version of Flash Builder 4. You can install the plug-in version if you are already using Eclipse for your programming environment. However, you will likely see some minor variations in the following steps. We also assume that you have a local, standalone installation of ColdFusion. You may need to make changes to the paths based on your custom installation.

  2. Select File > New > Flex Project as shown in Figure 1.
Create a new Flash Builder project.
Figure 1. Create a new Flash Builder project.

You will get the new project dialog box. Set up your new project as shown in Figure 2:

  • Name the project F4CF_Importing_CFC.
  • Be sure to use the default location for this example.

In the Server technology section of the dialog box, select ColdFusion from the Application server type drop-down menu. (Note that the Use remote object access service check box is selected by default when you select a server technology.)

  • Select the ColdFusion Flash Remoting option.
Set up your new project in the New Flex Project dialog box.
Figure 2. Set up your new project in the New Flex Project dialog box.
  1. Click Next.

Connect to the ColdFusion server

Follow these steps to configure your Flash Builder project to work with your ColdFusion server:

  1. In the Configure ColdFusion Server dialog box, select the options for your ColdFusion installation type.

    Figure 3 shows the settings if you are using the default installation of ColdFusion in Standalone mode on a PC.

Specify your ColdFusion server configuration.
Figure 3. Specify your ColdFusion server configuration.

Note: If you have used the default installation of ColdFusion in Standalone mode for a Mac OS X computer, your ColdFusion settings will likely be:

  • ColdFusion root folder: /Applications/ColdFusion9
  • Built-in ColdFusion web server web root: /Applications/ColdFusion9/wwwroot
  • Built-in ColdFusion web server root URL: http://localhost:8500
  1. Click the Validate Configuration button to ensure that the settings are correct.

    Note that the location of the Output folder is located within the ColdFusion server web root.

    Flash Builder automatically creates a folder named based on the project name and appended with –debug.

    In this case, the F4CF_Importing_CFC-debug folder is where Flash Builder will place the compiled Flash SWF and HTML wrapper files.

    Note: If you have the default installation of ColdFusion in Standalone mode for a Mac OS X computer, your Output folder setting is likely /Applications/ColdFusion9/wwwroot/F4CF_Importing_CFC-debug.

    Remember that Flash source files, unlike ColdFusion source files, are not deployed to the web server.

    Instead, you compile the source into a SWF file that is referenced in HTML wrapper files. The SWF and HTML files are uploaded to the server.

  2. Click Finish to create the Flash Builder project.

You will see the F4CF_Importing_CFC project in the Package Explorer, shown in Figure 4. Note also that the MXML application file with the same name is created and opened for editing. Note that Figure 4 shows the MXML Editor tab in Design mode. Click the Source button below the tab to see the Editor in code view.

The Flash Builder project in the Package Explorer
Figure 4. The Flash Builder project in the Package Explorer

The Flex framework provides two programming languages: ActionScript, which is a fully object-oriented language, and MXML, which is an XML-based language with similar syntax to CFML.

Introspect and import a CFC

Introspect and import a CFC

Now that your database, data source, and Flash Builder project are set up, you are ready to learn how easy it is to retrieve data from a CFC method and bind it to a Flex user interface element. Time to complete: 5 minutes.

Downloading the ColdFusion component

ColdFusion components are a way of organizing your business logic into reusable code. They were introduced in ColdFusion MX and replace the inline database query construct. In other words, instead of putting a cfquery tag at the top of your CFML page, you invoke the query that is placed into a CFC method, passing in arguments as necessary.

Note: Refer to the article Understanding the role of CFCs in Flex application development for more information on CFCs.

Note: If you generated the CFC's using ColdFusion Builder, then skip to Using the Data Services wizard to import a CFC section. Otherwise, continue with the following steps to download the CFC’s needed to continue with this exercise.

  1. Download and unzip the provided f4cf_ generated_cfcs.zip file on your local disk if you haven’t done so already.
  2. Move the F4CF_FictitiousSalesPlanner folder to the \\wwwroot directory.

Using the Data Services wizard to import a CFC

Next, you will import the CFC into the project using the Data/Services view in Flash Builder:

  1. Locate the Data/Services view in Flash Builder shown in Figure 5.

    (If the view is not open, select Window > Data/Services.)

The Data/Services view.
Figure 5. The Data/Services view.
  1. Click the Connect to Data/Service link to run the Data Services wizard.

    Note: You can also select Data > Connect to Data/Service to open the Data Services wizard.

  2. Select ColdFusion for the service type (see Figure 6).
Select the ColdFusion data service type.
Figure 6. Select the ColdFusion data service type.
  1. Click Next.
  2. For CFC Location, browse to C:\ColdFusion9\wwwroot\F4CF_FictitiousSalesPlanner\SALESTARGETSService.cfc and Click Open. See Figure 7.
Configure the ColdFusion Service.
Figure 7. Configure the ColdFusion Service.
  1. Click Next.
  2. In the Remote Service Authentication dialog box, shown in Figure 8, enter your RDS username and password.

Note: Be sure to have RDS enabled in the ColdFusion Administrator. Remember that the default username is admin.

Enter your credentials to authenticate RDS access.
Figure 8. Enter your credentials to authenticate RDS access.
  1. Click OK.

    Flash Builder accesses the CFC, introspects it, and returns information about the available operations and data types associated with those operations. You will see each method in the CFC displayed in the Service Operations window shown in Figure 9.

The Service Operations dialog displays the CFC methods.
Figure 9. The Service Operations dialog displays the CFC methods.
  1. Click Finish.

Flash Builder creates the service. You may see the instructions shown in Figure 10, if you have not previously selected the check box in the lower left corner of the Using Remote Services dialog box.

Instructions for using the remote service.
Figure 10. Instructions for using the remote service.

The rest of this tutorial steps you through these instructions.

  • Click OK to dismiss the Using Remote Services dialog box.
  • Locate the Data/Services view to see the CFC operations shown in Figure 11.
The introspected CFC operations.
Figure 11. The introspected CFC operations.

Note that the getAllSALESTARGETS() method name is followed by SALESTARGETS[]. When Flash Builder introspected  the CFC and provided information about the methods, it mapped the ColdFusion query that is returned from this operation to an Array data type.                    

Create a simple employee data display

Now that the CFC has been introspected into Flash Builder and the Flash Builder project is set up, you will use the returned data to create a simple employee data display. Time to complete: 5 minutes.

Reviewing the data types

In this section, you will review the SALESTARGETS Data Type within the Data Services view.

Expand the Data Types category in the Data/Services view to see that the SALESTARGETS data type is defined as an object that includes EMAIL, FIRSTNAME, and LASTNAME properties (see Figure 12).

The SALESTARGETS data type.
Figure 12. The SALESTARGETS data type.

Binding data to a Flex component

This section demonstrates how to bind the SALESTARGETS data type to a DataGrid component:

  1. Switch to Design mode in Flash Builder by clicking the Design button below the Editor tab (see Figure 13).
The Design view button.
Figure 13. The Design view button.
  1. Locate the DataGrid control of the Components view (see Figure 14).
The Flex Builder Components panel.
Figure 14. The Flex Builder Components panel.
  1. Drag and drop the DataGrid component into the Design view of the F4CF_Importing_CFC.mxml file as shown in Figure 15.
Add the DataGrid control to your application.
Figure 15. Add the DataGrid control to your application.
  1. Drag and drop the getAllSalesTargets() CFC function from the Data/Services view onto the DataGrid control to populate it with the SALESTARGETS data type.

    Leave the defaults in the Bind to Data dialog window and Click OK.

    The DataGrid control now has columns that match the properties in the SALESTARGETS data type. (see Figure 16)

The bound DataGrid control.
Figure 16. The bound DataGrid control.
  1. Select File > Save to save the MXML file.
  2. Click the Run (green round) button to test the file (see Figure 17).
Click the Run button.
Figure 17. Click the Run button.

Figure 18 shows the DataGrid control populated with the CFC data. Note that Flash Builder has opened the HTML wrapper file from the F4CF_Importing_CFC folder in the web root.

The DataGrid component populated by the SALESTARGETS data type.
Figure 18. The DataGrid component populated by the SALESTARGETS data type.

Where to go from here

In this tutorial, you set up the an Apache Derby sample database, and a ColdFusion data source. If you chose to, you generated a CFC using ColdFusion Builder. Then you set up a Flash Builder project to work with ColdFusion server technology. Finally, you experienced how easy it is to retrieve data from a CFC method and bind it to a Flex user interface element. To learn more how to build ColdFusion and Flex applications, visit the Flex and ColdFusion page in Flex Developer Center.

More Like This

  • Building a Flex application that connects to a BlazeDS Remoting destination using Flash Builder 4
  • Project Hendrix: A call center Customer Experience Management solution
  • Working with Doctrine 2, Zend AMF, Flex, and Flash Builder
  • Building a Flex application that connects to a BlazeDS Remoting destination using Flash Builder 4.5
  • Sending and receiving mobile text messages with Flex, ColdFusion, and BlazeDS
  • Introducing the MXML and ActionScript languages
  • Set up and build your first Flex and ColdFusion application – Part 1: Database setup
  • Generating ColdFusion forms with Adobe Flash Builder 4
  • Getting started with ColdFusion and Flash Builder 4 – Database, CFC, and data services setup
  • Understanding the role of CFCs in Flex application development

Tutorials & Samples

Tutorials

  • Flex mobile performance checklist
  • Flex and Maven with Flexmojos – Part 3: Journeyman
  • Migrating Flex 3 applications to Flex 4.5 – Part 4

Samples

  • Twitter Trends
  • Flex 4.5 reference applications
  • Mobile Trader Flex app on Android Market

Flex User Forum

More
07/25/2011 Flash Player Debug Issues - Safari 5.1 & Chrome 13
04/22/2012 Loader png - wrong color values in BitmapData
04/22/2012 HTTPService and crossdomain.xml doesn't work as expected
04/23/2012 Memory related crashes in Flex application

Flex Cookbook

More
04/06/2012 How to detect screen resize with a SkinnableComponent
02/29/2012 Embed Stage3D content inside Flex application components
02/15/2012 Custom WorkFlow Component
02/09/2012 Using Camera with a MediaContainer instead of VideoDisplay

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement