Out of curiosity, I think I know what's happening here and it's not that
Flash needs to be cleaned, but that the argument type is wrong.

In Flash an array can be either numeric or associative. Within CF those
translate into 2 different datatypes. Flash's Numeric array is the same as a
CF array and an associative array is the same as a Coldfusion Struct.

Change the argument on your proxy function to a Struct and you shouldn't
have any issues passing it along.

Cheers,

Kevin

-----Original Message-----
From: Clark Slater [mailto:[EMAIL PROTECTED] 
Sent: September 26, 2005 4:00 PM
To: CF-Talk
Subject: Recursive Functions in CFC

Hi Folks,

I'm using a CFC as a proxy for Flash remoting calls to Google Adwords API.
I've found that the Google SOAP services choke on complex object types and
Arrays sent from Flash unless I rebuild those objects in the CFC before
invoking the Google webservice (despite the fact CF has no trouble with the
datatypes!).

So, I'm trying to write a couple of recursive methods for the CFC that I can
use to sanitise these Flash datatypes for the webservice. Having trouble
getting it working though as I'm far more comfortable with Actionscript than
CF. On top of which I am sure there is a much more elegant way to handle
this.

I'd really appreciate if anyone out there could take a quick look over my
attempts at recursion and tell me where I'm going wrong. Right now using
these functions I am getting unwanted duplicate nested structs and arrays.

Thanks for any guidance,

Clark

<!-- Method to sanitise Flash Arrays for Google adwords API webservice -->
<cffunction name="sanitiseFlashArray" access="private" returnType="any">
<cfargument name="flashArr" type="array" required="yes">

<cfset newArr = Arraynew(1)>
<cfloop index="i" from="1" to="#Arraylen(flashArr)#">
<cfset tmpItem = #flashArr[i]#>
<cfif IsArray(tmpItem)>
<cfinvoke method="sanitiseFlashArray" flashArr="#tmpItem#"
returnvariable="newItem">
<cfset #newArr[i]# = #newItem#>
<cfelseif IsStruct (tmpItem)>
<cfinvoke method="sanitiseFlashObject" flashArr="#tmpItem#"
returnvariable="newItem">
<cfset #newArr[i]# = #newItem#>
<cfelse>
<cfset #newArr[i]# = #tmpItem#>
</cfif>
</cfloop>
  
<cfreturn "#newArr#">
</cffunction>
 

<!-- Method to sanitise Flash Objects for Google adwords API webservice -->
<cffunction name="sanitiseFlashObject" access="private" returnType="any">
<cfargument name="flashObj" type="struct" required="yes">

<cfset newObj = StructNew()>
<cfloop collection="#flashObj#" item="key">
<cfset tmpItem = #flashObj[key]#>
<cfif IsStruct(tmpItem)>
<cfinvoke method="sanitiseFlashObject" flashArr="#tmpItem#"
returnvariable="newItem">
<cfset #newObj[key]# = #newItem#>
<cfelseif IsArray (tmpItem)>
<cfinvoke method="sanitiseFlashArray" flashArr="#tmpItem#"
returnvariable="newItem">
<cfset #newObj[key]# = #newItem#>
<cfelse>
<cfset #newObj[key]# = #tmpItem#>
</cfif>
</cfloop>
  
<cfreturn "#newObj#">
</cffunction>





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:219350
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to