• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 17. Flash, ColdFusion, and the Da... > Sending Data from Flash to Coldfusio...

Sending Data from Flash to Coldfusion

The Flash movie is nearly complete. The only remaining task is to have the Finish button load the ColdFusion page and send the data to it.

Open dante_quiz.fla in Flash. Click Frame 40 of the actions layer and open the Actions panel.

This is the final script in the movie. In each of the four preceding scripts, after incrementing the score (if appropriate), the script used gotoAndStop() to advance to the next screen. Question 5, however, is the last screen. Rather than advancing to a new screen, you want to load dante_quiz_results.cfm.

Replace the comment “// Insert code here to send data to ColdFusion script” with the following code.


The getURL() behaves much like the <a> tag in HTML: It opens a new page in the browser.

At this point, though, no data is being sent. You need something like this:


The problem is, you obviously can't hard-code the values of the score variable (“5”) and the username variable (“osiris@allectomedia.com”). You need Flash to insert those values on the fly. Earlier, faced with the same challenge in a ColdFusion page, you used <cfoutput> to solve the problem. Obviously, <cfoutput> is not available in Flash. But an equivalent is.

Revise the getURL() line as follows:

getURL("dante_quiz_results.cfm?score=" + score + "&username=" + username);

Text inside quotation marks is ignored by Flash, which simply passes that text as-is. However, the text outside the quotation marks is evaluated by Flash. The + symbol between the text strings in quotes and the variable names outside the quotes are used to glue the pieces together; the programming term for this is concatenation. Thus, if the current value of score is 3, and the current value of username is rory@frogjuice.com, this line will be converted to the following, and will be sent as a request to the server.


Create a SWF (Control > Test Movie) and then close the movie once it appears. In Dreamweaver, find the dante_quiz.swf in the flash folder (within the Files panel) and upload it to the remote server. Click dante_quiz_login.cfm and press F12. Complete the quiz, and click the Finish button.

By choosing Control > Test Movie, you create a new version of the SWF file, complete with the new code. But you can't really test the movie in the Flash environment, so close it right away and go to Dreamweaver.

When you are finished taking the quiz, you should see dante_quiz_results.cfm. This page has nothing on it yet, beyond the placeholder text. But that doesn't matter—you'll fix that soon enough. Most importantly, notice in the address bar of the browser that the username and score variables have been passed into the URL. Since ColdFusion can see querystrings like this, you'll be able to grab that data and make use of it.

Save and close dante_quiz.fla.

Now it's time to return to Dreamweaver.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint