<!--- Tag attributes --->
<CFPARAM NAME="ATTRIBUTES.Data" TYPE="any">

<!--- If the passed-in value is a structure --->
<CFIF IsStruct(ATTRIBUTES.Data)>
  <!--- Start with an empty string --->
  <CFSET FinalString = "">

  <!--- For each value in the Data, add key/value pair to FinalString --->
  <CFLOOP COLLECTION="#ATTRIBUTES.Data#" ITEM="ThisKey">
    <!--- Get the value of this key/value pair --->
    <CFSET ThisValue = ATTRIBUTES.Data[ThisKey]>
    <!--- Make sure it's possible to express this value as a string --->
    <CFIF IsSimpleValue(ThisValue)>
      <!--- Add key/value pair to FinalString, with the value encoded --->
      <CFSET ThisPair = "#ThisKey#=#URLEncodedFormat(ThisValue)#">
      <CFSET FinalString = ListAppend(FinalString, ThisPair, "&")>
    </CFIF>
  </CFLOOP>

  
<!--- If the passed-in value is a query --->  
<CFELSEIF IsQuery(ATTRIBUTES.Data)>
  <!--- Start by providing the record count --->
  <CFSET FinalString = "RecordCount=#ATTRIBUTES.Data.RecordCount#">
  
  <!--- For each row in the query --->
  <CFLOOP QUERY="ATTRIBUTES.Data">
    <!--- Loop through the column names --->
    <CFLOOP LIST="#ATTRIBUTES.Data.ColumnList#" INDEX="ThisCol">
      <!--- Add key/value pair to FinalString, with the value encoded --->
      <!--- Resulting variable names will be in the form COLUMNNAME_ROW --->
      <CFSET ThisValue = Attributes.Data[ThisCol][CurrentRow]>
      <CFSET ThisPair = "#ThisCol#_#CurrentRow#=#URLEncodedFormat(ThisValue)#">
      <CFSET FinalString = ListAppend(FinalString, ThisPair, "&")>
    </CFLOOP>
  </CFLOOP>

<!--- Show an error message if value was not a structure or a query --->
<CFELSE>
  <CFTHROW
    MESSAGE="Error Encountered by &lt;CF_ExposeDataToFlash&gt;"  
    DETAIL="The value of the Data attribute must be a structure or a query.
            Don't forget to use pound signs around the query or structure name.">
</CFIF>

<!--- Output final string, using <CFCONTENT> to discard any prior output --->
<CFCONTENT TYPE="text/html" RESET="Yes"><CFOUTPUT>&#FinalString#</CFOUTPUT>