Click here to close now.

Welcome!

Adobe Flex Authors: Matthew Lobas, PR.com Newswire, Shelly Palmer, Kevin Benedict

Related Topics: Adobe Flex, ColdFusion, AJAX & REA

Adobe Flex: Article

Your First Adobe Flex Application with a ColdFusion Backend

The wow factor plus usability

Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the "wow factor" necessary to please clients and users alike, but the "usability factor" necessary to make your application a real success.

 Flex 2 has recently been released and can be downloaded at Adobe's Web site. This release includes Flex Builder 2 (an IDE based on Eclipse) and Flash Player 9. At Adobe's Web site, you'll also find tools specifically for ColdFusion such as the ColdFusion/Flex Connectivity package and ColdFusion extensions for Flex Builder. If you know how Flex 1.5 works, you'll be happy to hear that Flex 2 doesn't require a Flex server and that you can develop and deploy applications with Flex 2 for free using the Flex SDK (if you don't use the IDE).

A Flex application communicates to external services, and we find ColdFusion to be a perfect tool for providing those services. In this article, we'll walk you through the construction of an application with a Flex frontend and a ColdFusion backend. We believe that the integration with ColdFusion is so smooth you won't even notice you're transferring data from a remote server. The application you'll construct is a simple to-do list, but it will let us show you several Flex and ColdFusion features.

To start, you'll need the tools mentioned above, specifically Flex Builder IDE and the ColdFusion connectivity package and extensions downloaded and installed.

Setting Up Your Environment
The application will use a database with only one table, so you need to create a database with your favorite DBMS. This database should contain a table called "Task" with the following columns: id (varchar 35), description (varchar 1000), done (bit), and priority (smallint). Then register the data source in the CF administrator with the name "mytodolist."

Now you're ready to open Flex Builder and create a new project. While running the New Project wizard, specify that you'll be using ColdFusion Flash Remoting Services because the application will be communicating to your ColdFusion server via Flash Remoting rather than other alternatives such as XML or Web Services (see Figure 1). Assuming that you're running the development version on your local computer (http://localhost:8500), you can select "Use local ColdFusion server" in the second screen of the wizard. In the next screen enter "mytodolist" as the name of the project in the default location and finally, in the last screen, specify "http://localhost:8500/mytodolist/" as the Output folder URL.

The extensions you downloaded and installed include RDS support for viewing files and data sources. Make sure you have RDS enabled in your CF administrator and that you've set up the RDS preferences in Flex Builder. If your RDS connection is set up properly, you should be able to open the RDS Dataview (you can open it from Window > Other Views > RDS) and see the data source you created earlier (see Figure 2).

Running the ColdFusion Wizard
Another handy feature included in the ColdFusion extensions is the ability to run automatic generation of basic ColdFusion components. The "Create CFC" wizard will generate all the ColdFusion code you need for this application. Then you'll make a few changes to the components to meet specific needs. From the RDS Dataview, look for your data source ("mytodolist"), open the tables node, and right-click on the "Task" table to run the ColdFusion wizards > Create CFC option of the context menu (see Figure 3). This action will open a dialog that asks you what type of CFC you want and some other basic options. Make sure the CFC folder is your current project folder (mytodolist). Set the CFC package name to "mytodolist." Also check the option "The primary key is controlled by the user" because the component will set the id instead of letting the database choose the id. You also want to create an ActionScript value object that matches your Task CFC. So you need to check "Create an actionscript value object."

When you're finished, you should have three new files in your project: Task.cfc, TaskGateway.cfc, and Task.as.

Overview of the Application
The application consists of a list of undone tasks and a form to add a new task. Each task contains an icon that indicates its priority, a label that shows the description of the task, and a button that can mark the task done and remove it from the view. Figure 4 shows the finished application with styles applied.

To construct it, you'll use these components: VBox, Repeater, Panel, Button, Label, and form controls such as TextArea and ComboBox. You'll also create a custom component that will represent the view of each task item (TaskItem.mxml) and a custom component that will contain the edit form (EditForm.mxml). By creating custom components, you can reuse them throughout your application.

If you are wondering about the data, the application will get the list of tasks from a ColdFusion service and send requests to add new tasks and mark them as done.

Main Application File
The New Project wizard created an empty main application file called mytodolist.mxml. You'll use this file as the main canvas where you'll place the components and most of the ActionScript code. In a larger application, you will probably not want all your code in the same file, but for simplicity, you'll keep it there.

We have not yet described how to get the data from the server, but once the application gets the list of tasks, you'll need to store it in a local variable. To do that, declare the variable "tasks" inside a <mx:Script> block.

<mx:Script>
   <![CDATA[
      import mx.collections.ArrayCollection;

      [Bindable]
      private var tasks:ArrayCollection = null;
   ]]>
</mx:Script>

It's important to set this variable as "bindable" because you'll use it as the dataProvider of the repeater component.

In our layout, we want to have the list of tasks vertically positioned with one task below the other. By using a VBox component, we can add all the tasks and the VBox will position them how we want them. But the task list data will come from a ColdFusion service, so you don't know how many of them there'll be. So you'll use a repeater component that will "loop" over the collection of tasks and add them to the VBox.

<mx:VBox width="350">
<mx:Repeater dataProvider="{tasks}" id="taskList">
      <TaskItem taskData="{taskList.currentItem}" />
   </mx:Repeater>
</mx:VBox>

TaskItem Custom Component
If you save mytodolist.mxml file, you'll get an error indicating the TaskItem can't be resolved. This happens because we put the tag <TaskItem> inside the Repeater but the component TaskItem doesn't exist yet.

To create this custom component, you'll go to the File menu and click on New > MXML component. It will extend the Canvas and have 100% width because we want it to take the width of the parent container: the VBox. Save it as TaskItem.mxml.

More Stories By Nahuel Foronda

Nahuel Foronda is one of the founders of Blue Instant (http://www.blueinstant.com), a web development firm specializing in Rich Internet Applications where he has been creating award-winning applications and offering training for the last five years. He also maintains a blog, called AS Fusion (http://www.asfusion.com), where he writes about Flash, ColdFusion and other web technologies.

More Stories By Laura Arguello

Laura Arguello is one of the founders of Blue Instant (http://www.blueinstant.com), a web development firm specializing in Rich Internet Applications where she has been creating award-winning applications and offering training for the last five years. She also maintains a blog, called AS Fusion (http://www.asfusion.com), where she writes about Flash, ColdFusion and other web technologies.

Comments (17) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
??? 10/30/07 01:47:34 AM EDT

Ipod MP4

????
????
????
????
??
????
????
????
???
????
???? 

donna 10/12/07 01:28:46 PM EDT

Unable to download the source code. When I got to page http://www.asfusion.com/projects/my-to-do-list/

I received a Coldfusion error:

A License exception has occurred.
You tried to access the Developer Edition from a disallowed IPThe Developer Edition can only be accessed from 127.0.0.1 and two additional IP addresses. The additional IP addresses are: 209.85.238.20,87.194.221.84

There are so many issues encountered with the tutorial apps out there, that dont work when people follow the isntructions exactly. We need apps that work when followed, and we need downloaded source code that will actually be there.

Lara 07/30/07 11:59:27 AM EDT

I am familiar with ColdFusion but completly new to Flex. I can't get the code to work and I am very frustrated. This isn't a good first application example if we can't work the code. Does anyone have the working source files? If so, please post a link to the corrected files. Thanks!

Jason 06/26/07 02:20:44 PM EDT

I love all the article put out by sys-con and found that they are top quality, that is until this one. I have been struggling with learning Flex and found this article and initally was excited because it looked like the article that was going to clear things up. Until I started in and realized that this article is full of mistakes. Flex is VERY case sensitive where as ColdFusion is not. Since this article is target at ColdFusion developers you need to make sure that the code is correct expecially in the area of case sensitivity because we ususally don't think in that manner (it is "faultString" not "faultstring"). Also you need to make sure that you are using the same name for functions. You have us call the addItem() function through a click event but then on the next page we create the saveItem() function to handle that click event. This won't work! Then we need to make changes to the generated CFCs. You show us the two lines of code that we need to add and simply state that they "should be added to the 'create' method." Ok, but where in the create method. I moved them all over and I continually get errors. I have yet to find a competent article for the Flex "newbie" that achieves its goal of showing how to do basic updates and adds with Flex and CF. I thought that this was going to be the one. Guess I was wrong!

KTK 06/07/07 03:53:09 PM EDT

I'm glad it's not just me! I've had to put this aside for a couple weeks to work on a CF project. Hopefully I can get back to it later this month. If you figure something out, let me know and if I figure it out, I'll let you know. In the meantime, maybe a savior will come along for both of us!

Scott 06/07/07 01:30:06 PM EDT

KTK - I have the same problem and I followed all of the instructions exactly.

Uf!

KTK 06/04/07 01:28:59 PM EDT

I'm getting an error that says "A file found in a source-path must have the same package structure '', as the definition's package, 'Task'. I've been beating my head against it for hours and can't figure out why I'm getting the error. Any ideas?

jex 11/04/06 11:26:10 AM EST

OK - I'm a bit new to both Flex and CF, but have been implementing the tutorial fine up until: "Going back to the main application file (mytodolist.mxml), switch to the design view and drag a new panel and inside drag your EditForm component." When I drag the EditForm component onto the panel, nothing happens. Would it be possible to explain exactly what has to be done here? Many thanks.

jex 11/04/06 11:24:25 AM EST

Problem solved - I was trying to drag the EditForm.mxml - but it's the EditForm component(as it says in the tutorial)which needs to be dragged - this is found in the custom component folder.

jex 11/04/06 10:19:33 AM EST

OK - I'm a bit new to both Flex and CF, but have been implementing the tutorial fine up until: "Going back to the main application file (mytodolist.mxml), switch to the design view and drag a new panel and inside drag your EditForm component." When I drag the EditForm component onto the panel, nothing happens. Would it be possible to explain exactly what has to be done here? Many thanks.

Francois-Yanick Bourassa 08/09/06 04:21:30 PM EDT

I found myself a bit confused to follow this article as it is a bit out of the real target - which is bringing new people to use Flex and ColdFusion. As a ColdFusion programmer, I found very interesting to try this example with Flex. But after couple paragraphs, started to be confused on which file I was suppose to put the code as Flex is a real new thing for me - I'm sure it will be the same for few of us - if it is not more! We use to read article where editor just put rectangle on source code by page - but this article seems to have a different goal!

I will figure out what was wrong in the code because I think I can but what about newbies!!!

This was my personal feedback!

AJAXWorld News Desk 08/09/06 08:35:47 AM EDT

Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success.

cfdj news desk 08/08/06 08:29:03 PM EDT

Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success.

CFDJ News Desk 08/08/06 07:25:22 PM EDT

Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success.

AJAXWorld News Desk 08/08/06 07:11:51 PM EDT

Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success.

AJAXWorld News Desk 08/07/06 03:11:03 PM EDT

Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success.

SYS-CON Australia News Desk 08/07/06 09:34:46 AM EDT

Flex is a complete set of tools to develop rich Internet cross-platform applications based on the Flash platform. With Flex, you can create applications that not only have the 'wow factor' necessary to please clients and users alike, but the 'usability factor' necessary to make your application a real success.

@ThingsExpo Stories
One of the biggest impacts of the Internet of Things is and will continue to be on data; specifically data volume, management and usage. Companies are scrambling to adapt to this new and unpredictable data reality with legacy infrastructure that cannot handle the speed and volume of data. In his session at @ThingsExpo, Don DeLoach, CEO and president of Infobright, will discuss how companies need to rethink their data infrastructure to participate in the IoT, including: Data storage: Understanding the kinds of data: structured, unstructured, big/small? Analytics: What kinds and how responsiv...
Since 2008 and for the first time in history, more than half of humans live in urban areas, urging cities to become “smart.” Today, cities can leverage the wide availability of smartphones combined with new technologies such as Beacons or NFC to connect their urban furniture and environment to create citizen-first services that improve transportation, way-finding and information delivery. In her session at @ThingsExpo, Laetitia Gazel-Anthoine, CEO of Connecthings, will focus on successful use cases.
Sensor-enabled things are becoming more commonplace, precursors to a larger and more complex framework that most consider the ultimate promise of the IoT: things connecting, interacting, sharing, storing, and over time perhaps learning and predicting based on habits, behaviors, location, preferences, purchases and more. In his session at @ThingsExpo, Tom Wesselman, Director of Communications Ecosystem Architecture at Plantronics, will examine the still nascent IoT as it is coalescing, including what it is today, what it might ultimately be, the role of wearable tech, and technology gaps stil...
The true value of the Internet of Things (IoT) lies not just in the data, but through the services that protect the data, perform the analysis and present findings in a usable way. With many IoT elements rooted in traditional IT components, Big Data and IoT isn’t just a play for enterprise. In fact, the IoT presents SMBs with the prospect of launching entirely new activities and exploring innovative areas. CompTIA research identifies several areas where IoT is expected to have the greatest impact.
Wearable devices have come of age. The primary applications of wearables so far have been "the Quantified Self" or the tracking of one's fitness and health status. We propose the evolution of wearables into social and emotional communication devices. Our BE(tm) sensor uses light to visualize the skin conductance response. Our sensors are very inexpensive and can be massively distributed to audiences or groups of any size, in order to gauge reactions to performances, video, or any kind of presentation. In her session at @ThingsExpo, Jocelyn Scheirer, CEO & Founder of Bionolux, will discuss ho...
SYS-CON Events announced today that GENBAND, a leading developer of real time communications software solutions, has been named “Silver Sponsor” of SYS-CON's WebRTC Summit, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. The GENBAND team will be on hand to demonstrate their newest product, Kandy. Kandy is a communications Platform-as-a-Service (PaaS) that enables companies to seamlessly integrate more human communications into their Web and mobile applications - creating more engaging experiences for their customers and boosting collaboration and productiv...
Roberto Medrano, Executive Vice President at SOA Software, had reached 30,000 page views on his home page - http://RobertoMedrano.SYS-CON.com/ - on the SYS-CON family of online magazines, which includes Cloud Computing Journal, Internet of Things Journal, Big Data Journal, and SOA World Magazine. He is a recognized executive in the information technology fields of SOA, internet security, governance, and compliance. He has extensive experience with both start-ups and large companies, having been involved at the beginning of four IT industries: EDA, Open Systems, Computer Security and now SOA.
From telemedicine to smart cars, digital homes and industrial monitoring, the explosive growth of IoT has created exciting new business opportunities for real time calls and messaging. In his session at @ThingsExpo, Ivelin Ivanov, CEO and Co-Founder of Telestax, shared some of the new revenue sources that IoT created for Restcomm – the open source telephony platform from Telestax. Ivelin Ivanov is a technology entrepreneur who founded Mobicents, an Open Source VoIP Platform, to help create, deploy, and manage applications integrating voice, video and data. He is the co-founder of TeleStax, a...
The industrial software market has treated data with the mentality of “collect everything now, worry about how to use it later.” We now find ourselves buried in data, with the pervasive connectivity of the (Industrial) Internet of Things only piling on more numbers. There’s too much data and not enough information. In his session at @ThingsExpo, Bob Gates, Global Marketing Director, GE’s Intelligent Platforms business, to discuss how realizing the power of IoT, software developers are now focused on understanding how industrial data can create intelligence for industrial operations. Imagine ...
Operational Hadoop and the Lambda Architecture for Streaming Data Apache Hadoop is emerging as a distributed platform for handling large and fast incoming streams of data. Predictive maintenance, supply chain optimization, and Internet-of-Things analysis are examples where Hadoop provides the scalable storage, processing, and analytics platform to gain meaningful insights from granular data that is typically only valuable from a large-scale, aggregate view. One architecture useful for capturing and analyzing streaming data is the Lambda Architecture, representing a model of how to analyze rea...
SYS-CON Events announced today that Vitria Technology, Inc. will exhibit at SYS-CON’s @ThingsExpo, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Vitria will showcase the company’s new IoT Analytics Platform through live demonstrations at booth #330. Vitria’s IoT Analytics Platform, fully integrated and powered by an operational intelligence engine, enables customers to rapidly build and operationalize advanced analytics to deliver timely business outcomes for use cases across the industrial, enterprise, and consumer segments.
SYS-CON Events announced today that Open Data Centers (ODC), a carrier-neutral colocation provider, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place June 9-11, 2015, at the Javits Center in New York City, NY. Open Data Centers is a carrier-neutral data center operator in New Jersey and New York City offering alternative connectivity options for carriers, service providers and enterprise customers.
When it comes to the Internet of Things, hooking up will get you only so far. If you want customers to commit, you need to go beyond simply connecting products. You need to use the devices themselves to transform how you engage with every customer and how you manage the entire product lifecycle. In his session at @ThingsExpo, Sean Lorenz, Technical Product Manager for Xively at LogMeIn, will show how “product relationship management” can help you leverage your connected devices and the data they generate about customer usage and product performance to deliver extremely compelling and reliabl...
The explosion of connected devices / sensors is creating an ever-expanding set of new and valuable data. In parallel the emerging capability of Big Data technologies to store, access, analyze, and react to this data is producing changes in business models under the umbrella of the Internet of Things (IoT). In particular within the Insurance industry, IoT appears positioned to enable deep changes by altering relationships between insurers, distributors, and the insured. In his session at @ThingsExpo, Michael Sick, a Senior Manager and Big Data Architect within Ernst and Young's Financial Servi...
The IoT market is projected to be $1.9 trillion tidal wave that’s bigger than the combined market for smartphones, tablets and PCs. While IoT is widely discussed, what not being talked about are the monetization opportunities that are created from ubiquitous connectivity and the ensuing avalanche of data. While we cannot foresee every service that the IoT will enable, we should future-proof operations by preparing to monetize them with extremely agile systems.
There’s Big Data, then there’s really Big Data from the Internet of Things. IoT is evolving to include many data possibilities like new types of event, log and network data. The volumes are enormous, generating tens of billions of logs per day, which raise data challenges. Early IoT deployments are relying heavily on both the cloud and managed service providers to navigate these challenges. Learn about IoT, Big Data and deployments processing massive data volumes from wearables, utilities and other machines.
SYS-CON Events announced today that CodeFutures, a leading supplier of database performance tools, has been named a “Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9–11, 2015, at the Javits Center in New York, NY. CodeFutures is an independent software vendor focused on providing tools that deliver database performance tools that increase productivity during database development and increase database performance and scalability during production.
The explosion of connected devices / sensors is creating an ever-expanding set of new and valuable data. In parallel the emerging capability of Big Data technologies to store, access, analyze, and react to this data is producing changes in business models under the umbrella of the Internet of Things (IoT). In particular within the Insurance industry, IoT appears positioned to enable deep changes by altering relationships between insurers, distributors, and the insured. In his session at @ThingsExpo, Michael Sick, a Senior Manager and Big Data Architect within Ernst and Young's Financial Servi...
“In the past year we've seen a lot of stabilization of WebRTC. You can now use it in production with a far greater degree of certainty. A lot of the real developments in the past year have been in things like the data channel, which will enable a whole new type of application," explained Peter Dunkley, Technical Director at Acision, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that Intelligent Systems Services will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Established in 1994, Intelligent Systems Services Inc. is located near Washington, DC, with representatives and partners nationwide. ISS’s well-established track record is based on the continuous pursuit of excellence in designing, implementing and supporting nationwide clients’ mission-critical systems. ISS has completed many successful projects in Healthcare, Commercial, Manufacturing, ...