How to transfer data with Flash Remoting
In the Introduction to Flash Remoting post, I explained how to connect to a Flash Remoting gateway. I believe that the most difficult part when using Remoting, however, is knowing how to manage the transfer of data from and to the server. This transfer happens when Flash makes a call to a service and sends parameters, and when the server sends a response (not a void function). I will first briefly explain how to send and receive any type of data and then go through all the data types available and show you how to handle them.
Sending data to the server
The simplest method to send parameters to a CFC function is by sending them in order, separated by commas inside the call parenthesis.
If we have the following CFC function:
<cffunction name="addCartItem" access="remote" returntype="boolean">
<cfargument name="product_id" type="numeric" required="true">
<cfargument name="quantity" type="numeric" required="false">
<cfargument name="price" type="numeric" required="false">
<!--- Do something--->
<cfreturn true />
</cffunction>
We would call it by (get the data from some control, not hard coded like in this example):
var product_id = 462;
var quantity = 1;
var price = 10.50;
myService.addCartItem(product_id, quantity, price);
//or simply
myService.addCartItem(462, 1, 10.50);
But when our function requires a lot of parameters, this becomes tedious and error prone, since it’s very easy to mistakenly change the order of the parameters. A better way to send a lot of parameters is by sending an object (like an structure or hashmap) with key-value pairs that match our cfargument names:
var myArguments = {}; //or new Object();
myArguments.product_id = 462;
myArguments.quantity = 1;
myArguments.price = 10.50;
myService.addCartItem(myArguments);
//we could also use the abbreviated version:
myService.addCartItem({product_id: 462, quantity: 1, price: 10.50 });
Even another method is by using an “associative array” (very similar to the object method, but creating an array instead):
var myArguments = []; //or new Array();
myArguments["product_id"] = 462;
myArguments["quantity"] = 1;
myArguments["price"] = 10.50;
myService.addCartItem(myArguments);
Sending data to Flash
There is no trick here. To send data back to Flash, just use the cfreturn tag:
<cfreturn myData />
Remember that the type of the data that you are sending to Flash must match the data type specified in the returnType attribute of the cffunction tag.
We access this data in our handler functions. If we use the Service object (see previous post), specifying the handler function as
new RelayResponder(this, "onCallReceived", "onFault");
we will get the results in our onCallReceived function, and the data will be inside the ResultEvent object in the property “result”.
function onCallReceived ( re:ResultEvent ):Void {
var myData = re.result ;
}
If we are using the old method, then the data is directly in the “results” object
responseHandler.onResult = function(results: Object ):Void {
//use the results
}
In that parameter, which we just called “results”, we receive whatever was sent by the server. If it was a string, for example, we will use it directly: myInput.text = results. Note that we can name this parameter however we want, it doesn’t have to be called “results” (same for the ResultEvent parameter in the Service example)
Strings and numbers
Strings and numbers are the easiest data types to use, as they are natively handled in Flash and CF. You can send data coming from a text input: myInput.text or anything that can be converted to a String by using the toString() function.
Numbers are a little more difficult just because CF is not strictly typed and Flash is. Sending numbers from Flash will always work, even if we send them as strings, as CF will be able to convert them, unless of course, you send other characters besides numbers in the string.
From our previous example, the first argument is numeric:
<cfargument name="product_id" type="numeric" required="true">
We can supply that argument by:
myService.addCartItem(3);
//Or
myService.addCartItem("3"); //not the best method
You can always replace that with a variable:
myService.addCartItem(productInput.text);
Returning a number is straight forward if we set the returnType of the function as numeric:
<cffunction name="getFavoriteNumber" access="remote" returntype="numeric">
<cfset var myFavoriteNumber = 3 />
<cfreturn myFavoriteNumber />
</cffunction>
You can even return it as a string <cfreturn “3”/> and it will still work. If you do not specify the returnType or you specify it as “any” (not recommended), it will be received as a string, not as a number. To convert it to a number, use the val() function:
Boolean values
These behave in the same way as the numbers: from Flash to CF, anything goes, but from CF to Flash, they are all strings unless otherwise specified in the returnType attribute. Therefore, it is important to specify the returnType to boolean in our CFC function.
You can send any of these to a CF boolean argument (<cfargument name="active" type="boolean" required="true">)
myService.myFunction(true); //or false
myService.myFunction("yes"); //or "no"
myService.myFunction("true"); //or "false"
myService.myFunction(1); //or 0. For true, any non-zero value will do
All those will be accepted as boolean values by the function, and the argument can be used in boolean expressions as in
The same guidelines that I gave for numbers work for Booleans: always specify the returnType to boolean. But what happens if we want to set a boolean in an array and send that to Flash? We have a problem. They will be just strings, which means they will always evaluate to true when used in an expression: if (myReturnedValue) , which makes it a bug difficult to find.
So how do we ensure that Flash receives a boolean? Macromedia documentation says that we can send a 0/1, but that has never worked for me. The only way I found to make sure I am returning a boolean (if I am not returning the boolean directly so that I can specify the returnType), is to use the javacast function:
<cfset myBoolean = javacast("boolean",false) />
Arrays
Arrays can be sent either way without any problems. CF will receive an array in an arguments like:
<cfargument name="products" required="false" type="array"/>
The array can come from many different sources, such as a control’s dataprovider. It can also be created:
var myArray = [1,2,3];
myService.addCartProducts(myArray);
The arrays can also contain complex objects inside that follow all the other rules discussed here.
If we want to return an array from ColdFusion, we can set the returnType attribute to array:
<cffunction name="getProducts" access="remote" returntype="array">
<cfset var products = arraynew(1)/>
<cfset products [1] = "Product 1" />
<cfset products [2] = "Product 2" />
<cfreturn products />
</cffunction>
When we receive that on the Flash end, we just must remember that Flash array indices start at 0:
responseHandler.onResult = function( results: Object ):Void {
myInput.text = results[0];
//or loop over all the items received
for (var i = 0; i < results.length; i++){
//do something with the results[i] element
}
}
Structures and objects
ActionScript associative arrays and simple objects can be sent to CF and they will be received as key-value structures. If we have an argument type struct in our CFC function:
<cfargument name="product" required="false" type="struct"/>
we use the same technique as when passing many arguments in one object or array:
var cartItem = {}; //or new Object();
cartItem.product_id = 462;
cartItem.quantity = 1;
cartItem.price = 10.50;
Or
var cartItem = []; //or new Array();
cartItem ["product_id"] = 462;
cartItem ["quantity"] = 1;
cartItem ["price"] = 10.50;
So what’s the difference?
The main difference is that it cannot be the only argument supplied to the function. If we pass that as the sole argument it will be interpreted as the arguments coming as key-value pairs (the shortcut to send many arguments at once). That means that the function must have other arguments we need to supply, so that the struct is not the only one:
myService.addCartItem(cartItem,customerId);
Or just send a bogus second argument to fool the gateway:
myService.addCartItem(cartItem,"");
We can then access this structure from ColdFusion as:
arguments.product.product_id
The other way around should be simple, but it does have some caveats due to the case-sensitive nature of Flash. In ColdFusion there are basically two way of creating and populating an structure:
Method A:
<cfset myStruct = structnew()/>
<cfset myStruct.product_id = 1 />
Method B:
<cfset myStruct = structnew()/>
<cfset myStruct["product_id"] = 1 />
When these two structures are used within CF, there is no difference between them, because CF is case-insensitive. If we send that to Flash:
<cfreturn myStruct />
it will receive different structures depending on what method was used to create them. With method A, it will receive results.PRODUCT_ID or results["PRODUCT_ID"], while if method B was used, it will receive results.product_id or results["product_id"] (what we most likely intended and expect).
It’s interesting to note that if you send a component instance to Flash, it will receive only the public properties (defined by this.myProperty), but no matter how we defined them (even by this["myProperty"]), they will always be upper case.
RecordSets and queries
RecordSets are handy complex objects that can carry a lot of data, which we can manipulate, sort and show in controls such as data grids. But you may be wondering what is a RecordSet beginning with. In ColdFusion terms, a RecordSet is what a query becomes when it reaches Flash. It contains the names of the columns and an array of records. It has several functions we can use such as getItemAt() or getColumnNames(). Going over all the features of a RecordSet is beyond this article.
RecordSet can only go one way, from the server to Flash. In ColdFusion, we just send a plain query.
<cffunction name="getProducts" access="remote" returntype="query">
<cfset var products = "" />
<cfquery name="products" datasource="MyDataSource">
SELECT *
FROM product
</cfquery>
<cfreturn products />
</cffunction>
I hope this overview helps you understanding how to use Remoting in the different scenarios that you may encounter. If you have any question, fell free to post it in the comments.
PaulH
syntax like this:
var addressArgs={
address:address.text,
city:city.text,
state:state.selectedItem.data,
zipcode:zipcode.text
};
doesn't seem to be recognized by the CFC as an argument. always seem to have to deal w/these in the CFC using Flash.Params. any idea what i'm doing wrong?
thanks again. i love reading these things.
Laura
Are you trying to receive that as an struct argument?
<cfargument name="address" type="struct"/>
or you have individual arguments for each (address, city, etc)?
Neil Bailey
Welcome back! I was actually starting to go into withdrawal :-)
Yet another great posting. Thanks!
PaulH
Laura
To tell it to treat it as a structure, you must have another parameters in your function call, even if those do not exist in your cffunction (just because we do not have overloading in CF) and you will be receiving an unnamed argument, so you can do:
yourFunction(addressArgs,"");
PaulH
Laura
You can also encapsulate it in another object:
yourFunction({address:addressArgs});
Steve Walker
Thank you very much. This was so clear. Any chance you can add to this with an example of how to pass a variable from each of the Flash Form controls?
Rick
Brian Sloan
I am using cflogin and have it timeout after 20 minutes. In my application cfc files it checks to see if the user is logged in and if not makes them login and then continues the operation. Now that I am using remoting, if the users session timesout and they click on something that requires the remoting I get an error "Error while calling cfc:event handler exception." Is there a good way to catch this and popup a login screen or something? -- This would be a great post.
Thanks,
Brian
Todd
Been a while since the last post on asfusion...(grins and rubs hands together in anticipation of the next post)
dickbob
custService = new Service("http://localhost/flashservices/gateway", null, "customerData", null, null);
...exist outside the Flash "session"?
I'm trying to send some data out from Flash and want it to persist in a cfc object for a later getURL call to a .cfm page to be able to read and process.
The full requirement is for Flash to gather the data and then pass it out to CF to display in a popup window as a pdf.
Todd
How would I pass the entire contents of a cfgrid to the cfc?
Laura
You mean passing all the form controls in one big variable?
Rick,
You can output the query in a cfgrid, check
http://www.asfusion.com/blog/entry/populating-a-cfgrid-with-flash-remoting
Brian,
Yes, that would be a great post :)
I will try to write it when I get a chance. I think the best would be to check for a valid session in the remoting function (or call one that takes care of sessions) and if they user is not logged in, throw an exception you can catch in Flash. How you handle that would be up to you, from redirecting to a login screen or somehow show a login form without refreshing the page.
Todd,
That would be a great post too. Many people has asked me how to debug remoting. There are some errors you can catch and send an email or log it. Others it is more difficult.
dickbob,
No, each time you call a service, a new instance of that component is created. You can, however, reference a component residing in memory by calling it from the service component.
Todd,
I wouldn't recommend to pass the entire datagrid back to cf if the data is large. But if you really want to, you can send myGrid.dataProvider (if you loaded the grid normally, or used remoting but set the data provider as myGrid.dataProvider = results.items), otherwise use myGrid.dataProvider.items
Thomas
Well I'm new, the very definition of a newb i guess. Anyway, I am able to get all hooked up to my cfc. It's returning an array.
If I set it to a text field, like in the Flash help example, it will display all four items from the array. EG
function randomPicture_result(result:ResultEvent) {
messageDisplay.text = result.result[0];
}
However, what I need to do is set each value from the array to a variable. I'm gonna use each variable in an loader component as the end of a path, to display four images,
i just cant seem to figure out how to assign each value of the array to the variable i need.
i apologize to the flash vets for missing what must be obvious
Laura
I don't know if I understand correctly, but anyway, here is my answer.
It seems that you are returning a structure, with an element called result which is an array.
If so, then when you do result.result[0] you shouldn't get the 4 array elements, but only the first. If you are getting the four elements, it means the element result has an array, in which the first element is another array.
It's difficult to help you without looking at your remoting component.
Jason
I got stuck playing the remoting with structure
var sessionArgs = {};
sessionArgs.dsn = "#session.dsn#";
myService.getTest(sessionArgs,"");
Then I call it in my cfc
<cfargument name="mySession" required="false" type="struct" />
#arguments.mySession.dsn#
why mySession.dsn is undefined in arguments?
Anything wrong? thanks
Thomas
<cfcomponent>
<cffunction name="randomPicture" output="true" access="remote" returntype="array" >
<cfset Peopledirect = ExpandPath("/images/random_people/")>
<cfdirectory directory="#Peopledirect#" action="list" name="people" filter="*.jpg">
<cfset lstPeopleFileNames = valuelist(people.name)>
<cfif people.recordcount lt 4 >
not enough images to produce banner
<cfelse>
<cfset lstPeople= ListGetAt(lstPeopleFileNames,RandRange(1, people.recordcount))>
<cfloop condition="listLen(lstPeople) lt 4">
<cfset temp = ListGetAt(lstPeopleFileNames,RandRange(1, people.recordcount))>
<cfif listfind(lstPeople,temp) eq 0>
<cfset lstPeople = listAppend(lstPeople,temp)>
</cfif>
</cfloop>
</cfif>
<cfset randomPics = ListToArray(lstPeople)>
<!----
<cfset randomPics = ArrayNew(1)>
<cfset randomPics[1] = "#ListGetAt(lstPeople,1)#" >
<cfset randomPics[2] = "#ListGetAt(lstPeople,2)#" >
<cfset randomPics[3] = "#ListGetAt(lstPeople,3)#" >
<cfset randomPics[4] = "#ListGetAt(lstPeople,4)#" > ---->
<!---- <cfset randomPics = "Hello World"> ---->
<cfreturn randomPics>
</cffunction>
</cfcomponent>
Here's my full actionscript: (as you can see, i dont set the values of the array to variables and use the load, i just put the loads into the responder results. Also, im getting this weird thing where upon every fourth or fifth reload i randomly lose a picture. dif pics are lost.)
import mx.remoting.Service;
import mx.services.Log;
import mx.rpc.RelayResponder;
import mx.remoting.PendingCall;
import mx.rpc.ResultEvent;
// connect to service and create service object
var CFCService:Service = new Service (
"http://www.wordablaze.net/flashservices/gateway",
new Log(),
"cfcs.random_image",
null,
null );
// call the service
var pc:PendingCall= CFCService.randomPicture();
//get the result from from the service
pc.responder = new RelayResponder(this, "randomPicture_result");
//feed the result into the loaders
function randomPicture_result(re:ResultEvent)
{
image_loader_two.contentPath = "http://www.wordablaze.net/images/random_people/" + re.result[0];
image_loader_three.contentPath = "http://www.wordablaze.net/images/random_people/" + re.result[1];
image_loader_four.contentPath = "http://www.wordablaze.net/images/random_people/" + re.result[2];
image_loader_five.contentPath = "http://www.wordablaze.net/images/random_people/" + re.result[3];
}
stop();
Neil Huyton
We've tried embedding the swf in the cfform but this causes it to run real slow.
We can call a cfc from the flash movie but how can it be done so that it's not the caller (flash movie) that gets the results, but the cfform.
I'm pretty sure this can't be done, but I just thought I'd see if anybody has done this.
Thanks.
Fritz Dimmel
I just want to say thank you for your great site. This posting is one of many which helps me a lot in the last weeks!
Keep up this good work!
Fritz
Yogesh Mahadnac
First of all, thanks for all the information present on this website, it's truly of a great help! :-)
Ok, now, I've got 2 questions. Actually I've been trying to find the answer on Macromedia's ColdFusion forum but nobody has ever been able to answer me. I hope i'll have better luck here! So, please bear with me till the end... :-)
Here is the situation:
If my cffunction needs a lot of parameters from flash, the best thing would be to create an object (or structure as it is more commonly called in ColdFusion) in flash form actionscript, right? I also totally agree with that.
I quote:
var myArguments = {}; //or new Object();
myArguments.product_id = 462;
myArguments.quantity = 1;
myArguments.price = 10.50;
myService.addCartItem(myArguments);
But then, why is it that in my cffunction I cannot create a cfargument called e.g. myFlashData of type struct? I've noticed that I need to create a separate cfargument for each of the parameters of myArguments. i.e.
Instead of
<cfargument name="myFlashData" type="struct" required="yes">
I need to do
<cfargument name="id" type="numeric" required="yes">
<cfargument name="name" type="string" required="yes">
etc...
This is somehow weird, because I've also been using Actionscript in Flash MX 2004 and I've always created only 1 cfargument of type struct in my CFC and then I reference each key e.g. #arguments.myFlashData.id#, '#arguments.myFlashData.name#' etc in my cfquery.
2.
What I've also been doing every time in Flash MX 2004 Actionscript is to send the whole contents of my datagrid to my CFC to either add or update. But unfortunately I haven't been able to reproduce the same using Flash Forms.
E.g. If I have a button called Update, on the onclick event, I usually do
on(click) {
var myArr = new Array();
for(var i = 0; i < myGrid.length; i++)
{
var myData = new Array();
myData["id"] = myGrid.getItemAt(i).id;
myData["name"] = myGrid.getItemAt(i).name;
myData["addr"] = myGrid.getItemAt(i).addr;
myArr[i] = myData;
}
//and then I submit myArr to my CFC
myService.updateRecords(myArr);
//i'm sending the whole grid data as an array of structures to my CFC
}
And then in my CFC, I have my function called updateRecords
<cffunction name="updateRecords" access="remote" returntype="void">
<cfargument name="myArr" type="array" required="yes">
<cfloop index="i" from="1" to="#arrayLen(arguments.myArr)#">
<cfquery datasource="#application.myDsn#">
update myTable
set
name = '#arguments.myArr[i].name#',
addr = '#arguments.myArr[i].addr#'
where id = #arguments.myArr[i].id#
</cfquery>
</cfloop>
</cffunction>
Is there an equivalent or a way to possibly do this using Flash Forms? If yes, how do you create the array of structures in Flash forms actionscript? And how do you define your arguments in CFC?
Please advise on these 2 issues.
Thanks and regards
Neo
I have a question, How to refresh a cfgrid in a cffomr after update data from a cfform + remoting (cfc) without refreshing the browser window ?
thks
Neo
Yogesh Mahadnac
All you need to do is to call the function to populate your data grid immediately after you call the function to update the data.
E.g.
<!--- Make a call to add record to db --->
if( mx.validators.Validator.isStructureValid(this, 'myForm') ){
<!--- Set busy cursor --->
mx.managers.CursorManager.setBusyCursor();
myForm.myGlobalObjects.adjustment.createAndUpdate(myData);
}
<!--- Make a call to get adjustments for the selected element --->
myForm.myGlobalObjects.adjustment.getAdjustment(currency_cb.selectedItem.data);
In my function setUpRemoting, I have the following code:
<!--- Create default reponse handler objects --->
var responseHandler:Object = {};
<!--- put controls in the responseHandler's scope --->
var myGrid:mx.controls.DataGrid = myGrid;
<!--- handle search by default onResult function --->
responseHandler.onResult = function( results: Object ):Void {
if(results.length != 0)
{
myGrid.dataProvider = results;
}
else
{
alert("No record found for the broker selected!");
myGrid.removeAll();
}
mx.managers.CursorManager.removeBusyCursor();
}
So every time I update the data grid or add new items to it, I immediately call the function getAdjustment to populate myGrid with updated records.
Hope this helps.
Regards,
JohnDoe
Is there any way to get access to the raw results (in Flash I would have pumped it into a dataSet and then used it from there) or do I have to use an invisible DataGrid?
Neo
But I have another problem.
My problem is that when I've made a datagrid refresh when I'm upload a image that with the same name in the dababase (ex: in my database the inital image name is IMAGE1.JPG) if I upload an image with the same name, the refresh grid not work with the image field. But if I upload an image with a different name that thios is recorded in database, the refresh datagrid fucntion work fine...
So have you a solution to refresh the grid with image field even though the image name is the same already present in database field ?
Thks
Jimmy
I'm trying to do a cfgrid update based on a start date and end date. These 2 dates are selected by the user and the cfgrid would display the moment they start selecting. How would I pass the 2 dates and return the data back in the grid?
Luciano Gonzales
Laura
How do you know the server is not called?
I would use Fiddler or Live HTTP Headers (or any other http debugger) to see if the server gets call.
Macd
Here is a portion of the code:
<u>component called accessData.cfc</u>
<cfcomponent>
<cffunction name="checkLogin" displayName="Checking user login" access="remote" returntype="query">
<cfargument name="username" required="yes" type="any">
<cfargument name="password" required="yes" type="any">
<cfset var rscheckLogin = " ">
<cfquery name="rscheckLogin" datasource="dataset">
select * from users where username = '#username#' and
password = '#password#'
</cfquery>
<cfreturn rscheckLogin>
</cffunction>
</cfcomponent>
<u>Actionscript to call this cfc</u>
if (inited == null) {
inited = true;
NetServices.setDefaultGatewayUrl("http://the domain/flashservices/gateway");
gatewayConnection = NetServices.createGatewayConnection();
loginService = gatewayConnection.getService("accessData", this);
}
loginService.checkLogin(username_ti.text, password_ti.text);
here is the result code:
function checkLogin_result(rslogin) {
trace('CheckLogin result');
if (rslogin.length > 0) {
gotoAndStop("ondemand");
} else {
status_lbl.text = "<font color=\"#EFDFDC\">invalid user name / password.</font>";
// set the form focus to the username_ti TextInput instance and select the existing text.
Selection.setFocus(username_ti);
Selection.setSelection(0, username_ti.text.length);
}
}
Lesley
Steve
I get an error when I try to do it that says: The argument DATAGRIDDATA passed to function testGridToCFC() is not of type Struct. I also tried Array, Query, object, and others all with the same result (naming the type I used of course).
I tried myGrid.dataProvider and myGrid.dataProvider.items all with the same result.
What I'm trying to do is populate a grid through remoting (not a large grid), let the user edit it, and then submit the changes back to the cfc.
Any ideas?
Steve
I'll post the function to my blog a little later.
Joel
Joel
Laura
Most of it will work and the idea is the same, although you might need some updates to the syntax. What it won't work is the section "Sending data to Flash" as that has changed.
Darren
var productData:Array = [
{title:"Brindley Place 1", fullsize:"dtl_Central_Square_1.jpg", thumb:"thmb_Central_Square_1.jpg", view:"view_Central_Square_1.jpg", zip:"zip_Central_Square_1.zip", description: "One of the UK’s largest new city centre squares", collectionID: 1}];
i can see the array in a trace command but can't seem to get at it, or moreover gid rid of all the other gubbins that gop with it, heres the trace:
11/29 23:42:59 [INFO] : Invoking argent on cfdocs.argent.code.gallery.remoteservices
11/29 23:43:0 [INFO] : cfdocs.argent.code.gallery.remoteservices.argent() returned {_items: [{__ID__: 0,
collectionID: 1,
description: "One of the UK?s largest new city centre squares",
fullsize: "dtl_Central_Square_1.jpg",
thumb: "thmb_Central_Square_1.jpg",
title: "Brindley PLace",
view: "view_Central_Square1.jpg"},
{__ID__: 1,
collectionID: 1,
description: "One of the UK?s largest new city centre squares",
fullsize: "dtl_Central_Square_2.jpg",
thumb: "thmb_Central_Square_2.jpg",
title: "Brindley PLace",
view: "view_Central_Square2.jpg"}],
gateway_conn: {__originalUrl: "http://192.168.1.250:8500/flashservices/gateway",
__urlSuffix: "?;jsessionid=a4301a3220aa75782c28",
contentType: "application/x-fcs"},
logger: {level: 0, name: ""},
mRecordsAvailable: 2,
mTitles: ["collectionID", "fullsize", "thumb", "view", "title", "description"],
serverInfo: null,
uniqueID: 2}
can't i just grab the array out, i don't need anything else
Laura
When you send a query via remoting, you receive a RecordSet object. It contains a variable, "items" that is an array with the data.
Matt
Here is the code that works in 'helloWorld2.cfm':
<cfset session.level = 3>
<cfset session.minutes = 8>
<cfset tempStruct = StructNew()>
<cfset tempStruct.level = session.level>
<cfset tempStruct.minutes = session.minutes>
<cfdump var="#tempStruct#">
<cfset flash.result = tempStruct>
If I remove those first two lines of code, so that 'session.level' and 'session.minutes' are not defined in 'helloWorld2.cfm' but rather in my main ColdFusion page which contains the Flash movie and populates those values correctly, I get the 'undefined' message in the Flash movie where 'level' and 'minutes' should appear with the data.
I hope this makes sense. Any assistance you can provide is greatly appreciated. Thanks for your help!
JoelJ
Thank You,
Joel
Luciano
JoelJ
vinod
"Data source slideShow could not be found."
Karon E
<cfformitem type="script">
function GetMasterList(){
var responseHandler = {};
responseHandler.onResult = function( results: Object ):Void {
}
responseHandler.onStatus = function( stat: Object ):Void {
}
mx.remoting.NetServices.setDefaultGatewayUrl("http://ispdev.wff.nasa.gov/flashservices/gateway/");
var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection();
var myService:mx.remoting.NetServiceProxy = connection.getService("isp_cfcomponents.GetMaster", responseHandler);
myService.GetMaster(cmbPlanType.value, 1);
{
</cfformitem>
Steve
This is a test project that sends a barcode id from one SWF text field to a CFC that queries the database and returns a first name and last name to another SWF text field.
I've looked at a multitude of remoting examples and can't figure out how to send and receive the data (or access it).
ActionScript Code
import mx.remoting.Service;
import mx.rpc.RelayResponder;
import mx.rpc.ResultEvent;
import mx.remoting.PendingCall;
if (isGatewayOpen == null) {
isGatewayOpen = true;
// Make the Gateway connection
NetServices.setDefaultGatewayUrl("http://127.0.0.1:8501/flashservices/gateway");
gatewayConnnection = NetServices.createGatewayConnection();
checkIn = gatewayConnnection.getService("testing.components.receive_send", this);
trace("Connected");
}
new RelayResponder(this._parent, "onCallReceived", "onFault");
//results in our onCallReceived function
//data will be inside the ResultEvent object in the property “result”.
trace("RelayResponder connected. Data in OnCallReceived function");
function onCallReceived ( re:ResultEvent ):Void {
var myData = re.result ;
}
callButton.onPress = function(){
//want to set the text field to the returned data from CFC
name.text =
}
stop()
I'm confident that the CFC is working. I tested with a CFM page. Here's the CFC code
<cffunction name="getDelegate" access="public" returnType="query">
<cfargument name="barcode" type="string">
<CFQUERY NAME="getDelegate" Datasource="BDM">
SELECT concat(ucase(left(d_fname,1)),substring(d_fname,2)) as "fname",
concat(ucase(left(d_lname,1)),substring(d_lname,2)) as "lname"
FROM delegates
WHERE d_barcode = 13564358456
</CFQUERY>
<cfreturn getDelegate>
</cffunction>
</cfcomponent>
Any help would be appreciated.
Thanks!
Steve
Herbert
how can i pass ALL the form variables including grid-data to a remoting-cfc in one big structure? (like the form structure in cf)
regards
herbert
Herbert
how can i get a meaningful structure from cfgrid data in my cfc?
how can i get this cfgid-values, sent with flashremoting
var myform= myform;
myService.submitform(myform);
back to a "real" structure?
__CFGRID__EDIT__=2nameYageY3UAlliciaAlicia3323UAllanAlan3430UAdamssAdams2423
thanks in advance
herbert