Welcome!

You will be redirected in 30 seconds or close now.

ColdFusion Authors: Yakov Fain, Jeremy Geelan, Maureen O'Gara, Nancy Y. Nee, Tad Anderson

Related Topics: Adobe Flex, ColdFusion, SYS-CON MEDIA

Adobe Flex: Article

Getting Started with Adobe Flex 2

Flex, as I'm sure most people know, is a way for programmers to create Flash movies

I'm going to postpone the second part of my RSS aggregator article to tie this column into this Flex-themed issue. Have no fears, though, it will be back in full force in the next issue. Flex, as I'm sure most people know, is a way for programmers (you, me, and us) to create Flash movies.

 The focus of Flex is not on animation and drawing little fancy pictures; it's on creating advanced interfaces, which are used to create Rich Internet Applications (RIA). It is a "Flash for programmers"-oriented product. Macromedia had long been pushing the concept and benefits of Rich Internet Applications, so it's great to see Adobe taking up the charge and finally making them accessible to all.

Flex 2 was released at Adobe's CFUNITED keynote (a few days ago to me), so this issue seems appropriately timed. I thought I'd take the space in this beginner's column for an overview of Flex 2 and talk about why you want to care.

Putting the Pieces Together
Everyone who has seen Flex from the beginning viewed it as an amazing and revolutionary product. If you think of ColdFusion as a way to build HTML pages on the fly, Flex was a way to build Flash movies on the fly. Unfortunately, most people found the price tag to be a serious setback to Flex usage. Adobe has addressed those concerns head on with the release of Flex 2.

These are the components that make up the Flex 2 suite of products:

  • ActionScript 3: The language of Flash has always been ActionScript. With the release of the Flash 9 Player comes a new version of ActionScript. ActionScript has always been used to provide advanced functionality in a Flash movie.
  • MXML: MXML stands for Maximum Experience Markup Language and is a form of XML. You can use MXML to create Flash movies with Flex. Most things in ActionScript have a parallel in MXML, and vice versa.
  • Flash 9 Player: Flex applications will run only on Flash Player 9. Flash Player 9 adds support for ActionScript 3, and offers many performance enhancements over Flash 8.
  • Flex SDK: The Flex SDK is everything you need to build Flex applications. It contains a command-line compiler along with all the built-in Flex components (which includes a bunch of user interface elements). You can write MXML code in any editor of your choice, use the SDK to compile it to a swf file, and then deploy it to a Web server of your choosing. There have been rumors that Adobe hopes the release of the SDK will allow for the creation of third-party tools for generating Flex applications. I haven't heard of any tools being built yet, but this definitely bodes well for the long-term release of the community. Did I mention that the Flex SDK is free?
  • Flex Builder 2: Flex Builder 2 is an Eclipse-based editor for building Flex applications. Although you can use the Flex SDK to build them for free, Flex Builder offers many advantages, including tag insight and a step-through debugger. Flex Builder is available as a standalone product or as an Eclipse plug-in. I like to use the plug-in version so that my Flex applications can easily reside next to CFEclipse applications.
  • Flex Charting Components: The Flex charting components are available as a standalone package or as an add-on to Flex Builder. They make it easy for you to generate charts in Flex, as well as allow for drill down and roll over functionality.
  • Flex Data Services: Flex data services allow you to push data to the browser. It integrates with ColdFusion very nicely through the use of an event gateway. This is a feature that was unavailable in Flex 1.5, and can be very powerful in some applications.
Those are the important pieces of Flex. You can download the Flex components from the Adobe Website at www.adobe.com/cfusion/tdrc/index.cfm?product=flex. You can update your Flash player at www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash. For the remainder of this article, I'm going to give you an introduction in how Flex and ColdFusion work together. When working with Flex 2 and ColdFusion, you'll want to install the ColdFusion 7.02 updater. You can download that from www.adobe.com/support/coldfusion/downloads_updates.html .

Accessing a CFC from Flex
Flex can call CFCs directly using Flash Remoting; an update to ColdFusion's Flash Remoting components is located in the 7.02 updater. This update helps ColdFusion talk to something you built in Flex. To demonstrate, I'll start with a simple helloworld.cfc:

<cfcomponent>
<cffunction name="GetHello" output="false" access="remote" returntype="string">
    <cfreturn "Hello World">
    </cffunction>
</cfcomponent>

If you are not familiar with CFCs, there are a plethora of resources for learning about them. You might start with one of my previous columns on them at http://coldfusion.sys-con.com/read/47203.htm. This component has no instance variables and only contains a single "GetHello" method. The method returns the string "Hello World." This is simple stuff, and you all know it, right? Great, let's look at some Flex code!

First, you'll need to define a Flex application, like this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
</mx:Application>

All the MXML code that you write will go in the mx:Application block. In CFML, all tags start with CF. In MXML, all tags start with "mx:". Code blocks work the same way in either language. The mx:Application works, conceptually, the same way that a cfloop does. Now we can add a label and a button to our code:

<mx:Label id="Result" x="59" y="58"/>
<mx:Button x="154" y="56" label=" Get Hello"/>

Remember that this code goes in the mx:Application block. I used Flex Builder 2 to easily place the label and button, but if you are using the SDK without Flex Builder, you can specify the location of the elements using the x and y coordinates as shown in the code. This code will show you an empty label with a button next to it. The label, at present, doesn't contain any text. The button displays the text "GetHello" but doesn't actually do anything yet. The label is given an ID "result". This is so we can reference it later to assign it a value. I did not give the button an ID because we won't need to access it programmatically.

Next you need to tell Flex how to find your CFC. To do that, I used the RemoteObject tag and placed this code in my MXML file:

<mx:RemoteObject id="helloWorld" destination="ColdFusion" source="htdocs.experiments.flex.helloworld">
    <mx:method name="GetHello" result="GetHello_handler(event)" />
</mx:RemoteObject>

More Stories By Jeffry Houser

Jeffry is a technical entrepreneur with over 10 years of making the web work for you. Lately Jeffry has been cooped up in his cave building the first in a line of easy to use interface components for Flex Developers at www.flextras.com . He has a Computer Science degree from the days before business met the Internet and owns DotComIt, an Adobe Solutions Partner specializing in Rich Internet Applications. Jeffry is an Adobe Community Expert and produces The Flex Show, a podcast that includes expert interviews and screencast tutorials. Jeffry is also co-manager of the Hartford CT Adobe User Group, author of three ColdFusion books and over 30 articles, and has spoken at various events all over the US. In his spare time he is a musician, old school adventure game aficionado, and recording engineer. He also owns a Wii. You can read his blog at www.jeffryhouser.com, check out his podcast at www.theflexshow.com or check out his company at www.dot-com-it.com.

Comments (1) 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
Web Developer's & Designer's Journal 08/10/06 04:30:18 PM EDT

I'm going to postpone the second part of my RSS aggregator article to tie this column into this Flex-themed issue. Have no fears, though, it will be back in full force in the next issue. Flex, as I'm sure most people know, is a way for programmers (you, me, and us) to create Flash movies.

@ThingsExpo Stories
When growing capacity and power in the data center, the architectural trade-offs between server scale-up vs. scale-out continue to be debated. Both approaches are valid: scale-out adds multiple, smaller servers running in a distributed computing model, while scale-up adds fewer, more powerful servers that are capable of running larger workloads. It’s worth noting that there are additional, unique advantages that scale-up architectures offer. One big advantage is large memory and compute capacity...
Artificial intelligence, machine learning, neural networks. We’re in the midst of a wave of excitement around AI such as hasn’t been seen for a few decades. But those previous periods of inflated expectations led to troughs of disappointment. Will this time be different? Most likely. Applications of AI such as predictive analytics are already decreasing costs and improving reliability of industrial machinery. Furthermore, the funding and research going into AI now comes from a wide range of com...
No hype cycles or predictions of zillions of things here. IoT is big. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, Associate Partner at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He discussed the evaluation of communication standards and IoT messaging protocols, data analytics considerations, edge-to-cloud tec...
"When we talk about cloud without compromise what we're talking about is that when people think about 'I need the flexibility of the cloud' - it's the ability to create applications and run them in a cloud environment that's far more flexible,” explained Matthew Finnie, CTO of Interoute, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
We build IoT infrastructure products - when you have to integrate different devices, different systems and cloud you have to build an application to do that but we eliminate the need to build an application. Our products can integrate any device, any system, any cloud regardless of protocol," explained Peter Jung, Chief Product Officer at Pulzze Systems, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
In his session at @ThingsExpo, Eric Lachapelle, CEO of the Professional Evaluation and Certification Board (PECB), provided an overview of various initiatives to certify the security of connected devices and future trends in ensuring public trust of IoT. Eric Lachapelle is the Chief Executive Officer of the Professional Evaluation and Certification Board (PECB), an international certification body. His role is to help companies and individuals to achieve professional, accredited and worldwide re...
The Internet giants are fully embracing AI. All the services they offer to their customers are aimed at drawing a map of the world with the data they get. The AIs from these companies are used to build disruptive approaches that cannot be used by established enterprises, which are threatened by these disruptions. However, most leaders underestimate the effect this will have on their businesses. In his session at 21st Cloud Expo, Rene Buest, Director Market Research & Technology Evangelism at Ara...
SYS-CON Events announced today that Enzu will exhibit at SYS-CON's 21st Int\ernational Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enzu’s mission is to be the leading provider of enterprise cloud solutions worldwide. Enzu enables online businesses to use its IT infrastructure to their competitive advantage. By offering a suite of proven hosting and management services, Enzu wants companies to focus on the core of their ...
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
Amazon started as an online bookseller 20 years ago. Since then, it has evolved into a technology juggernaut that has disrupted multiple markets and industries and touches many aspects of our lives. It is a relentless technology and business model innovator driving disruption throughout numerous ecosystems. Amazon’s AWS revenues alone are approaching $16B a year making it one of the largest IT companies in the world. With dominant offerings in Cloud, IoT, eCommerce, Big Data, AI, Digital Assista...
SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
SYS-CON Events announced today that GrapeUp, the leading provider of rapid product development at the speed of business, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company, specialized in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market acr...
SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara California. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infras...
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, discussed some of the security challenges of the IoT infrastructure and related how these aspects impact Smart Living. The material was delivered interac...
In his session at Cloud Expo, Alan Winters, an entertainment executive/TV producer turned serial entrepreneur, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to ma...
IoT solutions exploit operational data generated by Internet-connected smart “things” for the purpose of gaining operational insight and producing “better outcomes” (for example, create new business models, eliminate unscheduled maintenance, etc.). The explosive proliferation of IoT solutions will result in an exponential growth in the volume of IoT data, precipitating significant Information Governance issues: who owns the IoT data, what are the rights/duties of IoT solutions adopters towards t...
SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.