Setting up Remoting with Flex & ColdFusion

/, Flash Remoting, Flex/Setting up Remoting with Flex & ColdFusion

To get Coldfusion and flash to talk to each other is just as easy in Flex as it is in flash. Remember Flex is just the tool, and nothing more. When you compile flex you are just created a swf! To start this out I am just setting up the remoting call, later I will write a full app, which I have been meaning to do, but I have been too busy with school lately. You can check out flexcf Which as so many great examples of using this technology. It is run by Paul who has helped me a great deal in CF in the past! You can check out his blog too.

The mxml file


<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()" layout="absolute" pageTitle="Remoting Example" backgroundColor="White">

    <mx:Script>

        <![CDATA[

            import mx.rpc.events.ResultEvent;

            import mx.utils.ObjectUtil;

            import mx.controls.Alert;



            [Bindable]

            public var cfcResponse:String;



            //this gets called when the application is done being created

            public function initApp():void{

                //this calls the confirmCFC method in remoting.cfc

                cfc_ro.confirmCFC();

            }



            public function loadConfirm(event:ResultEvent):void{

                //this binds the cfcResponse var to the result of the RO call

                cfcResponse = event.result as String;

            }



        ]]>

    </mx:Script>



    <mx:RemoteObject id="cfc_ro" destination="ColdFusion" source="com.flex.remoting" showBusyCursor="true">

        <mx:method name="confirmCFC" result="loadConfirm(event)" fault="Alert.show(ObjectUtil.toString(event))"/>

    </mx:RemoteObject>

    <mx:Label text="{cfcResponse}" width="100%" />



</mx:Application>

the cfc


<cfcomponent output="false">



	<cffunction name="confirmCFC" returntype="any" access="remote">

		<cfreturn "This is a test to see if Flex is conecting to ColdFusion, from the file remoting.cfc">

	</cffunction>



</cfcomponent>

By | 2009-02-22T21:21:02+00:00 February 22nd, 2009|ColdFusion, Flash Remoting, Flex|4 Comments

About the Author:

4 Comments

  1. Paul Kukiel February 22, 2009 at 9:45 pm

    Great that we were able to help out with some references and that your enjoying working with Coldfusion and Flex.

    Dale Fraser is the owner of http://www.flexcf.com and http://www.learncf.com he wrote the framework on which the site is built in. I just maintain it for him.

    http://nuframework.riaforge.org

    Thanks for your support and look forward to some tutorial submissions. šŸ™‚

  2. admin February 22, 2009 at 10:19 pm

    Hi Paul,

    Yeah I love working with Flex & CF it is so much fun! I just found out that you can also skin a flex app too`-` I want to show this to my boss who is using flash instead of flex for this reason. The main app is in fact better for flash, as there are tweens,and other timeline stuff, but for the data processing, I think that flex is superior to flash.

    I didn’t know that Dale was the owner,and thought that it was you. I know Dale he has helped me a great deal on CF-Talk as well`-`

  3. Dale Fraser February 22, 2009 at 10:56 pm

    Flex is really good at skinning, Flex 4 is even better.

    We recently skinned the Flex Video Player, was easy and looks good.

  4. admin February 24, 2009 at 12:52 am

    Hi Dale,

    Yeah I found ScaleNine’s website,and have looked at their skins which is mostly a CSS approach. It is amazing how easy it is to use these skins. I have yet to try the video player in flex. Still learning from the Flex Explorer.

    I didn’t know that Flex 4 was out yet, I should look on the Labs site.

    Thanks for your comments.

    John

Leave A Comment