Add Comment
Class Binding Tutorial
ColdFusion Tutorial #6
This tutorial demonstrats how to bind a ColdFusion class to an ActionScript (Flex) class.
Tutorial6.mxml
This is a very basic example, that creates a couple instances of a ColdFusion object, these are mapped into an equivalent (but different) ActionScript object.Person.as
For this to work, the number of parameters and the order of these parameters need to match exactly in the .CFC and .as objects.Person.cfc
The object must have public properties to be picked up and mapped in the ActionScript class.Demo
See this code running!
Download
Download this code as a zip!
Comments
Some things to watch out for:1. Add the alias attribute to the cfcomponent tag and make sure it matches the alias in the AS class exactly.
2. If you return the Value Object (which these are, BTW) as members of an array, you might need to first instantiate the VO once in your AS (at any place in your code) for the transformation to occur.
-Oliver
Oliver Merk @ Friday 18 Apr 2008 - 08:38:11 PM
Two caveats here that I bump into all of the time:
1. If your server-side CFC extends another CFC, it must list its base class's properties as <cfproperty> tags as well.
2. The bits that transform your CFC to an AS3 class also understand "getter" and "setter" conventions: instead of having your properties be public, you can write getFoo() and setFoo() <cffunctions>.
Joe Rinehart @ Saturday 19 Apr 2008 - 01:34:30 AM
so in essence this action script code has the same methods as the cfc it is bound to, being you can use them and not redeclare them?? just like extending a class the .as will inherit everything from the .cfc or am i missing something
ethyreal @ Tuesday 06 May 2008 - 07:42:34 AM
@ethyreal,
No it is really for VO (Beans) getting the data into objects, you can not call the CFC methods from the AS object.
Dale Fraser @ Thursday 08 May 2008 - 04:47:58 AM
Click button to add a comment
Author
Dale Fraser