Groups | Blog | Home
all groups > coldfusion flash integration > april 2006 >

coldfusion flash integration : Flash Remoting


Rick
4/1/2006 9:18:01 PM
I am not sure if I am going to say this right. But here goes. I am try to
use Flash Remoting with my cfform (Flash). What I want to do is two things.

Is this possible?

One show an alert if under certain conditions.

Two make a certain Tab active under certain conditions. (tabnavigator)

Here is my cfc remoteing file that gets called.

<cffunction name="gettax" output="false" description="Returns the current
time"
access="remote" returntype="string">
<cfargument name="SState" required="false" type="string" default=""/>
<cfargument name="stax" required="false" type="string" default=""/>

<cfif ucase(arguments.SState) is "NC">
****** show alert here *****
<cfset stax = 0.059>
<cfelse>
******* Make tab index 2 active. *******
<cfset stax = 0>
</cfif>

<cfreturn stax />

</cffunction>

Thanks for any help you can give!!!

Rick
4/1/2006 9:33:29 PM
Is there any references you can give me to the AS check? I am unfamiliar
with that.

Thanks!!!

[quoted text, click to view]

Rick
4/1/2006 9:44:21 PM
I am sorry for my ignorance but this is ActionScript correct? Where does
this go in the main cfm file correct? How is it called?

Thanks Again!!


[quoted text, click to view]

doug777
4/2/2006 12:00:00 AM
doug777
4/2/2006 12:00:00 AM
If you are using flash remoting then it goes in the result handler of
the remoting function which will either be in the flash form or in an AS
page in your movie presumably.

doug777
4/2/2006 12:00:00 AM
I just realize that what you mean by make tab 2 active is this:

tnav.selectedIndex = 1;

not .enabled

doug777
4/2/2006 12:00:00 AM
If in formgroup tabnavigator id="tnav"

var tnav=tnav
responseHandler.onResult = function(results:Number):Void {
if(results) {
alert("This sales tax is excessive");
} else {
tnav[1].enabled=true;
}
}

doug777
4/2/2006 12:00:00 AM
You can't do it directly in the CFC. You can either use the returned
variable stax and then in the AS check whether it's 0 or >0, or if there
are more options, make stax a structure and add whatever you want to it
and then look through the object in AS, or you could add the items to a
list (as long as the order is always the same) which looks like a string
to AS then convert it to an array in AS and loop through the array.

As you find the items in AS you can perform whatever action you want:

alert("This sales tax is excessive");

tnav[1].enabled = true;

and so on,
Rick
4/2/2006 7:04:52 AM
I am beginning to understand how this works.

Is there a way to do a conditional if statement based on what is retuned
instead of if something is returned? Like this...but this does not work.


responseHandler.onResult = function(results:Number):Void {
stax.text = results;
if(results = 10) {
alert("This sales tax is excessive");
} else {
tnav.selectedIndex = 1;
}
}

Thanks for all your help!!


[quoted text, click to view]

Rick
4/2/2006 8:50:22 PM
Like Javascript I see.

Thanks!!


[quoted text, click to view]

Rick
4/2/2006 9:11:23 PM
I would like to send two variables over to the cfc file but one seems to get
ignored. Is my code wrong? Can I make two calls like that?

//get service. First parameter is path to component and
//the second it's the object that will handle the response
myService = connection.getService("cgi-bin/flashRemotingResponder",
responseHandler );
//make call
myService.gettax(SState.text);
myService.gettax(SCity.text);

You have been a lot of help I realy apreshate it.

Rick


[quoted text, click to view]

doug777
4/3/2006 12:00:00 AM
You can simply send them both together:

myService.gettax(SState.text, SCity.text);

Then in the cfc put two cfargument in the same order.
<cfargument name="stateText" type="string" required="yes">
<cfargument name="cityText" type="string" required="yes">

The value in SState.text will end up in the cf variable stateText and so
on for as many arguments as you want.

doug777
4/3/2006 12:00:00 AM
If you type if (results = 10) {} then results will always equal 10
because what you are saying is: set results equal to 10, so the if will
always be true.

If you want to check the equivalence of results and 10, you have to use
the equivalence operator which is == (is equivalent to)

so if you type if (results == 10) {} you will get the desired result.

Rick
4/3/2006 9:21:28 AM
Thanks soooo much!!!

Rick
4/3/2006 12:10:17 PM
How about on the return. Is there a way to return more than one variable?
Something like

if(results.stax == -1) {

Thanks again!!

[quoted text, click to view]

Rick
4/3/2006 12:11:53 PM
Would you use more of these?

<cfreturn qty />
<cfreturn stax />

Thanks!!

[quoted text, click to view]

Rick
4/3/2006 12:44:30 PM
Ok I figured out how to get more than one variable back but how do I loop
through and separate them.

responseHandler.onResult = function(results:Number):Void {
stax.text = results;
}

what I am getting looks like this.

57.34,99.00

I want to put 57.34 in the stax field and 99.00 in the shipping field.

Thanks for ALL you help!!!

[quoted text, click to view]

Rick
4/3/2006 10:11:44 PM
This worked sooooooo great!!!!!!

Thanks!!!


[quoted text, click to view]

doug777
4/4/2006 12:00:00 AM
You're right, you can only return one thing from a function, but that
thing can be a query, a structure (and for both these the AS return type
should be Object), a string, a number and what you've got this time, a
list. Since this is a list, your variable type should be results:String,
not :Number.

Unfortunately AS does not have any list handling capabilities, so you
need to turn this into an array. In flash forms we can't use the 'new'
keyword so do it like this:

var retarray:Array = results.split(",");

Now retarray[0] will equal 57.34 and retarray[1] will equal 99.00, so

stax.text = retarray[0];

Always glad to be of help, but I'm off the forum for a while so if you
want more help I suggest you start a new thread.

AddThis Social Bookmark Button