BLOG-N-PLAY.COM
Truth ain't stranger than fiction - just offered less frequently.

TOP THREE LINKS YOU MUST CLICK ON


Getting Started with Adobe Flex 2
Flex, as I'm sure most people know, is a way for programmers to create Flash movies

The code, once again, goes inside the application block. The RemoteObject tag has an ID, which allows us to access it in code, a destination that is a special distinguisher, and the source. The source is the Web location of your CFC. When accessing the CFC remotely, it must be Web accessible (unless you change settings to allow you to access CFCs via a ColdFusion mappings, but such a configuration is beyond the scope of this article). Inside the RemoteObject block there is one method that we respond to: "GetHello". The mx:method tag accepts two arguments: a name and the result. The name is the name of the method on the CFC. The result is the name of a local method that will be called when the Flash Player gets the results from calling that event.

The next step in our code base is to write the GetHello_Handler, which is written in ActionScript. You can put ActionScript in a MXML page using the mx:Script tag:

<mx:Script>
<![CDATA[
    import mx.rpc.events. ResultEvent;
    import mx.utils.ObjectUtil;

private function GetHello_handler( event:ResultEvent):void {
    Result.text = ObjectUtil.toString(event.result);
    }
]]>
</mx:Script>

After the script tag comes the CDATA. This tells the XML parser to ignore the text in the script tag. ActionScript is not a valid XML dialect. (I'm not saying that's bad, though.) Then I import the two objects that are used in the function. Importing objects in this manner is not common in ColdFusion development, but if you've worked with older versions of ActionScript or Java, you've probably seen it. It just says, "I need this object, so make it available to me."

The function should look similar to a CFScript function; I specified the function as private. Then comes the function keyword, followed by the name of the function. Next comes the list of arguments. This function only has a single argument, the ResultEvent. Then comes a colon followed by the return type. This function doesn't return anything. The one line of code takes the result from our function call, translates it to a string, and assigns it to the text of our Result label. It sounds more complicated than it actually is.

Type in the code (or copy and paste from the Web version), compile it, and execute it. You should see something similar to Figure 1. Click the button. Unfortunately nothing happened as the button was not told what to do yet. A click event needs to be added to the button. The new button code will look like this:

<mx:Button x="154" y="56" label="Get Hello" click="helloWorld.GetHello()"/>

The click event refers to the helloWorld remote object and says, "Execute the GetHello" method on that object. You should recognize this syntax for calling the method from your use of CFCs inside ColdFusion. When the button is clicked, the Flash player goes to the remote object and calls the method. When the method result is returned, the Flash player looks for the "mx:method" tag and executes the result function. Recompile the code and try it out. Click the button and you should see the Hello World text display next to the button (see Figure 2).

Conclusion
Adobe has done a fantastic job of making ColdFusion the best back-end tool for developing Flex applications. Included with Flex Builder are some Eclipse extensions that work well with ColdFusion, including RDS support and some code generators. I'm just scratching the surface of what can be done with Flex and how you can combine it with ColdFusion. I'd love to see what you are going to do with this technology, so be sure to let me know! See you in a month.

About Jeffry Houser
Jeffry Houser has been working with computers for over 20 years and in Web development for over 8 years. He owns a consulting company and has authored three separate books on ColdFusion, most recently ColdFusion MX: The Complete Reference (McGraw-Hill Osborne Media).

SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

ADS BY GOOGLE
LATEST ARTICLES, NEWS & POSTS
Although virtualization is an ideal building block for a cloud environment, saying that "virtualization" is the only basis for cloud computing is wrong. Notably Google uses little to no virtualization technology and is seen as the poster child for the cloud computing movement. Th...
VMware’s ESX hypervisor has become the first third-party hypervisor accredited under Microsoft’s months-old Server Virtualization Validation Program (SVVP). The validation applies to VMware ESX 3.5 update 2 (ESX 3.5u2) and means VMware customers who run Windows Server and Mic...
Unlike wireline service, mobile phones rely on often precarious over-the-air radio transmissions to carry time-sensitive voice traffic. Add to this the transforming of voice calls into IP-routed traffic; microphones and speakers disconnected from the device via Bluetooth; high-ba...
Federal Judge Susan Illston has found that Oracle CEO Larry Ellison either destroyed or deep-sixed e-mail evidence that should have been turned over for discovery in a 2001 insider-trading class-action suit. The suit, which Oracle wants quashed, claims that Ellison and other ...
What Apple has done with its App Store is show the world that the key to monetizing the cloud is in the delivery of the key applications and assets (music, video, ringtones) through a simple and accessible channel. In the last few weeks Microsoft, Google and T-mobile have all ann...
We need services like Feedburner and Yahoo Pipes to provide the service they say they will. I know they’re not bound by the kind of service level agreements that would be in place if we were actually paying them, but they surely have to operate within the bounds of, well, opera...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS

LIVE NEWS FROM THE WIRES

SilkRoad technology, inc., the leading provider of Sep. 7, 2008 07:00 PM

ShoreTel(R), Inc. (Nasdaq: SHOR), a leading provider of Pure IP Unified Communications solutions, to...
Valencia Ventures Inc. (TSX VENTURE: VVI) is pleased to announce that it has hired Ms. Salisha Hosei...
Avion Resources Corp. ("Avion Resources" or "the Company") (TSX VENTURE: AVR), today announced the a...
Allana Resources Inc. (TSX VENTURE: AAA) ("Allana"), is pleased to announce that it has hired Ms. Sa...