Everybody knows that it’s not possible to use Flash Remoting to call a cfc from a flash form. Furthermore, one of the limitations that the flash forms have is that they do not allow writing the keyword "new" (except in cfcalendar :) ), so we cannot use it to create a new remoting connection.
Everybody knows that it’s not possible to use Flash Remoting to call a cfc from a flash form. Furthermore, one of the limitations that the flash forms have is that they do not allow writing the keyword "new" (except in cfcalendar :) ), so we cannot use it to create a new remoting connection.
But we can use a different approach. Instead of using Remoting, we can use the loadVariables function. Although this method is not as powerful as Flash Remoting, it works great for small calls. Note is that this is not a solution for sending recordsets back and forward to the server. For complex and robust applications, I recommend taking a look at Flex (that allows to do this and much more). With loadVariables we can send and receive variables but not structures, queries, Arrays, or Objects (at least not without a parser).
The example that follows will make a simple call to a cfc and receive a variable back. It calls a cfc with one parameter (mask) that tells the CFC the mask to format the current date and shows the results received from the component.
var dataholder = this.createEmptyMovieClip('dataholder',4587);
dataholder.method = "getDate";//the cfc method
dataholder.mask = textEntered.text; //the parameter mask the component expects
dataholder.loadVariables ('dateResponder.cfc', 'POST');//note the component name with full path
var display = display;
var obj = {};
//we must check whether the data has already loaded
var checkData = function(obj)
{
if(dataholder.time != undefined)
{
clearInterval(obj.id);
display.text = dataholder.time;
dataholder.time = undefined;
}
}
obj.id = setInterval(checkData, 100, obj);
mmmm dd of yyyy
hh:mm:ss
The component should output any variable in the loadvars compatible format. It should also have access="remote" and return type void.
&time=#time#&eof=true
A live example
Download the source
Update: We found that it is possible to use Flash Remoting, so look at this post to see how to use it.