Your First ASP Page
The following example is the "Hello World" example. We will be sending a simple string to display in Flash. The first step is to create the ASP page, so here is the code:
If you were to test this script right now in a browser, it would display the text as it is, but from the previous chapter you learned that Flash will need this data in name/value pair format. So change the Response.Write line to the following:
<%@Language=VBScript%>
<%Option Explicit%>
<%
Response.Write("Hello World!!")
%>
Save the script as helloWorld.asp and put it on the server. Next up is the Flash part, so open Flash and follow these steps:
Response.Write("message=Hello World!!")
| 1. | Create a new Flash document and save it as helloWorld.fla . |
| 2. | In the Actions panel of the first frame, place this code:
|
The first thing that happens in the preceding code is that a text field is created to display the message being returned. Next up is the LoadVars object, which will connect to the ASP page to get the message. After that, we set up the onLoad event callback for when the data is received. In it, we pass the parameter success to make sure there were no problems connecting to the ASP page. If success is true, the message is displayed in the text field we created; if not, an error is sent to the Output panel. Finally, we call the load method to get the data by passing it the full path to ASP page. If you were to put this on a server, you would not need the full path to the script, just a relative path.Test the movie, and you should see a result similar to Figure 21.2.
Figure 21.2. The results of your first integration between Flash and ASP.
[View full size image]

Similar to the previous example, this example sends back a single name/value pair to Flash. This time, however, it uses the Now function to get the current time and date on the server. Also notice that an ampersand (&) is used to combine strings in VBScript. Save this script as geTDateStamp.asp and put it on your server. If you like, you can test the page to see what is being returned by simply mapping to it with a browser.Now for the Flash part:
<%@Language=VBScript%>
<%Option Explicit%>
<%
Response.Write("stamp=" & Now())
%>
This code is very similar to the previous example, except we mixed it up a bit by setting the
