views:

223

answers:

2

Using flex 3 with the coldfusion plugin, can I not write a standalone coldfusion class which I can invoke from my flex website (mxml)?

Thanks

+2  A: 

You can invoke methods in a standalone ColdFusion CFC using RemoteObject. Note these methods should 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 CFC using [RemoteClass(alias="ColdFusionCFC")]. This allows you to pass objects between ColFusion and Flex.

Brett
+1  A: 

You need to have the ColdFusion server running to actually use the CF class - sorry if that seems overly obvious but you didn't mention that you were running CF so I wanted to make sure that was covered :)

Other than that, you can most certainly write a CF class/component (CFC) with any tool, although some are more helpful than others. Check out CFEclipse.org for the free Eclipse plugin editor. Adobe also has release ColdFusion Extensions for Eclipse that will generate a CFC based on an ActionScript class, and also from a Database model (http://www.adobe.com/support/coldfusion/downloads.html). Those tools can help save you some typing.

RaeLehman