Figure Flash+asp realize electronic interactive map Online labeling function _ Application skills

Source: Internet
Author: User
Tags define function
In the electronic interactive map of the amount of information is too large, fully through the client's vast number of operators to complete the work of the large, so you must realize the function of online tagging. And this kind of function relies on flash itself is unable to realize alone. We can use ASP, asp.net, PHP and other assistance to achieve. In this case, we use ASP to implement the online tagging function together.

  1, the basic communication process


Fig. 1 schematic diagram of communication process between Swf+xml and server
Click to see the big picture

Figure 1 shows the communication process in this example. Server-side scripts that pass information between Flash and databases read and write data in XML format.
Use ActionScript to convert the information gathered in the SWF file into an XML object, and then send the data to the server-side script as an XML document. You can also use ActionScript to load the XML document returned by the server into an XML object to use the document in the SWF file. In this case, saving the relevant XML data is done by the server's scripting program, which is also the focus of this example.

2. The communication method between Flash and ASP

A variety of communication methods can be used between flash and ASP communication, and the Loadvars object is used in this example.
Loadvars can deliver variables to the server by using the Post method.

3, Server script

The server script can be written by a variety of programs, in this case, the ASP as an example to write related scripts.
Microsoft Active Server Pages (ASP) is a server-side scripting environment that you can use to create and run dynamic, interactive Web server applications.
Scripting languages are written using the relevant scripting language, which is the language between HTML and programming languages such as Java, C + +, and Visual Basic. HTML is typically used to format text and link pages. Programming languages are often used to send a series of complex instructions to a computer. Scripting languages can also be used to send instructions to computers, but their syntax and rules are not as rigorous and complex as the compiled programming language. Scripting languages are used primarily for formatting text and using compiled components written in a programming language.

ASP makes it possible for WEB developers to write complete procedures in a variety of scripting languages. In fact, multiple scripting languages can be used within a single. asp file.

We can use any of the scripting languages whose corresponding script engine is installed on the WEB server. Typically, both VBScript and JavaScript are used, where the ASP default scripting language is VBScript. This example writes a script in VBScript.

Let's take a look at the specific examples produced here.
Example production:

1, Flash end


First, create the following interface, the code to capture the points mentioned in the previous lecture, this example is only in addition to the name of the names, add some basic information, the method is the same, and here will not repeat it, and eventually assign the code that needs to be saved to the string variable SENDDATA_SRT.


Figure 2 SWF file interface 1
Click to see the big picture

Figure 3 SWF file Interface 2

Accept the message from the server with a variable named link. A value of 1 indicates a successful communication connection to the server side. Use
Loadvars, then use the Sendandload method to send the data under a loadvars entity.

Open the action panel of the timeline and enter the following ActionScript code:

function senddata (): Void {//define function to send data

var senddata = new Loadvars (); Constructs a new Loadvars object

senddata.check = 1;//Set Check action for server authentication

senddata.data = SENDDATA_SRT; Assign the data variable SENDDATA_SRT to be sent to the

output_txt.text = "Please wait ..."; The status text is displayed as "Please wait ..."

senddata.onload = function (success) {//authentication and server-connected functions

if (Success) {//If a successful connection to the server The

if (this. link== "1") {//If the validation action succeeds

else {

output_ Txt.text = "Server busy, please try again later!" ";

//return failure if the connection to the server is unsuccessful

senddata.sendandload ("http://www.wanggesz.com/XMLData/Save.asp", SendData, "post");

//send pending Save data

   2, Write server script (ASP)

Create an ASP file with the following contents:

<% @Language = "VBScript"%>

<%

Dim Check ' defines a check variable to validate data from a SWF file

Dim link defines the link variable, which is used to return to the SWF file, indicating that the communication was successful

Dim data ' defines the data variable, which is used to receive the stored information from the SWF file

Set data = Request.Form ("data") ' receives the pending save from the SWF file

Set Check = Request.Form ("check") ' Validate data from SWF file

If Check = 1 Then ' If the SWF file is properly identified

link = 1 ' Sets the link value to 1 to indicate a successful communication

End If ' ending if statement

Set xml=server.createobject ("Microsoft.XMLDOM")
' Create an object to manipulate the XML file

Xml. Async=false

Xml. Validateonparse=false

Xml. Load (Server.MapPath ("Http://www.wanggesz.com/XMLData/data.xml"))
' Load XML file

Set Newnode=mxml.createnode ("element", "Data", "")
' Create a new node NewNode, and life is data

Root.appendchild (NewNode)
' Append a new node newnode to the root node of the loaded XML file above.

Set objname = Mxml.createattribute ("Data")
' Create a property item objname for the newly created node. Text = Data Add property value for new property item

Xml.save (Server.MapPath ("Http://www.wanggesz.com/XMLData/data.xml"))
' Saves the XML file in the specified path,

Response.Write "Link" &link ' returns link=1 to SWF file

%>


In turn, we have completed the operation of the map, the marking of place names and other functions, and in the use of the map, the name of the search and location is also an essential common function.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.