How do I write a separate ColdFusion class in Flex 3?

Using Flex 3 with the ColdFusion plugin, can I write a separate ColdFusion class that I can call from my flex website (mxml)?

thank

0


source to share


2 answers


You can call methods in a stand-alone ColdFusion CFC using RemoteObject. Note that these methods must be marked with access = "remote" in ColdFusion.

<mx:Script>
    <![CDATA[
    private function callMethod():void
    {
      ro.MethodName;
    } 

    private function resultHandler(evt:ResultEvent):void
    {
      //Handle result
    }

    private function faultHandler(evt:FaultEvent):void
    {
     // Handle fault

    }
    ]]>
</mx:Script>
<mx:RemoteObject id="ro" destination="ColdFusion" source="ColdFusionCFC">
    <mx:method name="MethodName" result="resultHandler" fault="faultHandler"/>
</mx:RemoteObject>

      



You can also link Flex classes to ColdFusion CFCs using [RemoteClass (alias = "ColdFusionCFC")]. This allows objects to be transferred between ColFusion and Flex.

+2


source


You need the ColdFusion server to work in order to actually use the CF class - sorry if that seems too obvious, but you didn't mention that you are running CF, so I wanted to make sure it was closed :)



Other than that, you can of course write a class / component CF (CFC) with any tool, although some are more useful than others. Check out CFEclipse.org for a free Eclipse plugin editor. Adobe also released ColdFusion Extensions for Eclipse, which will generate CFCs based on the ActionScript class as well as from the database model ( http://www.adobe.com/support/coldfusion/downloads.html ) These tools can help you do a little typing ...

+1


source







All Articles