Environment communication
Communication with the server
Most of commercial Web Sites extensively use communications between client's computer and the server. Every time you are asked to login, or when you buy products online, or when you search for some keyword you communicate with server.
For example when you enter your username and password and click Submit button you invoke a long chain of events. First you send your name and password to the page with server-side script. When executing this script server connects to the database and request information from the account table. List of users is searched accordingly to your username and password. If matching record is found then you are redirected to some certain page. Some additional information from account table may be displayed. In case there is not correct username or password you are thrown back to the login page with a message.
It's out of scope of our course to immerse in server-side technology, but we'll illustrate on example how "front-end" of such application may be done in Flash.
Look at the example below. At the left part you may see two input text boxes. Enter the password and user name there and click the button. The new page must load with your account information. If you provided incorrect name or password – the "wrong name" message will be displayed.
Code for "Send" button is fairly simple. It does exactly what any HTML form does. You may recreate this example, but be sure that variables assigned to input texts named "userid" and "pass".
on(release) {
getURL("http://myservername.com/account.asp", "_blank", "POST")
}
However code on the server side is quite complicated and may look approximately like that. Code is written in VBScript with SQL and executes using ASP technology. You'll need a special account with ASP libraries available to implement such code.
‘this is only example
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("mydatabaselocationhere")
Set rsData=Server.CreateObject("ADODB.Recordset")
strSQL= "SELECT * FROM mytablenamehere WHERE userid='" & Request("userid") & "' AND pass='" & Request("pass") & "'"
rsData.Open strSQL,Conn, 2,3,1
If rsData.EOF = true Then
Response.Write("Sorry, wrong name")
Else
Response.Write("First Name=" & rsData.Fields("fname").Value)
Response.Write("
Last Name=" & rsData.Fields("lname").Value)
Response.Write("
Age=" & rsData.Fields("age").Value)
Response.Write("
E-Mail=" & rsData.Fields("email").Value)
Response.Write("
Country=" & rsData.Fields("country").Value)
End If
There are more methods of server communication in Flash including XML sockets, but general idea is presented here.