First, the ASP reads the Access database.
Copy Code code as follows:
<% @language = "VBScript" @codepage = "65001"%>
<%
' Open an explicit variable declaration
Option Explicit
' Set Output type
Response.contenttype= "Text/xml"
' Defines three variables, conn (Connection object), ConnStr (ConnectionString), SQL (an SQL statement)
Dim conn,connstr,rs,sql,i
' Defines the value of the ConnectionString
I=1
Connstr= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &server.mappath ("Test.mdb") & ";"
' Establish a Server connection object
Set Conn=server.createobject ("ADODB. Connection ")
' Set up DataSet objects
Set Rs=server.createobject ("ADODB. RecordSet ")
' Open Data connection
Conn.Open ConnStr
' The meaning of this sentence is to get the values of the first 100 Song1name,dong1url fields in ascending order of the ID field values in the word datasheet. Values are attached to a DataSet object as a property of the dataset.
Sql= "SELECT top [Song1name],[dong1url] from [test] ORDER by id DESC"
' Cursor type and lock type are set to 1, which is a forward-only read-only behavior, the fastest read
Rs.Open sql,conn,1,1
Response.Write ("<?xml version= ' 1.0 ' encoding= ' utf-8 '?>< ', Amoy >")
' Do a while loop, and the condition loops to the last item that meets the criteria
Do as not rs.eof
' This is the modified section so that the output file can be identified by the Loadvars object in Flash.
Response.Write ("< song information >< song name >" &rs ("Song1name") & "</song name >< address >" &rs ("Dong1url")) & "</address ></song information >"
' Record Move Down
Rs.movenext
I=i+1
' Loop method with Do while echoes, the main loop body
Loop
Response.Write ("</Amoy >")
' Close the DataSet object
Rs.close
' Close the database connection
Conn.close
' Releasing DataSet resources
Set rs=nothing
' Free database connection resources
Set conn=nothing
%>
This part of the code is to read the database.
Here's how to generate the XML, in fact, is in the output time. Plus the appropriate format for the XML. such as < song information, and each label. Be sure to note that each label must be closed.
The full code for this xml.asp file is as follows:
Below, and then see how flash in the loading of it?
In this, it should be very simple.
Copy Code code as follows:
Defining components
var My_TextArea:mx.controls.TextArea;
var my_List:mx.controls.List;
var my_xml:xml = new XML ();
My_xml.load ("http://www.taoshaw.com/taoshaw/study/accessAndList/xml.asp");
My_xml.onload = function (Ok:boolean) {
if (OK) {
For (i=0 I[TD] My_list.additem ({label:this.firstchild.childnodes.childnodes[0].childnodes[0].nodevalue, data: This.firstchild.childnodes.childnodes[1].childnodes[0].nodevalue});
}
}
};
var my_object:object = new Object ();
My_object.change = function (eventobj:object): Void {
My_textarea.text + = eventobj.target.selecteditem.label+ "\ n";
};
My_list.addeventlistener ("Change", my_object);
In this way, the resulting XML file is imported into the list. Through the monitoring function, the data can be invoked.
Learn this, for the production of some projects with background, such as albums, dynamic article management, players and so on is not difficult.
To make some flash that needs to be loaded with external files, it is particularly necessary to note the coding problem.
First of all, to note that in the same flash, do not appear two times: "System.usecodepage=true";
The original meaning of this sentence is to load the external non-"Utf-8" format of the encoding of the file into the uft-8 format, and if used two times, there will be errors.
The general method of cooperation is to choose the Uft-8 encoding format, or Gb2312 This format, when the external file is saved. As for the detailed distinction between the two codes, I am still not clear, I hope you have a clear friend, but also pointing at the next.
I have no meaning in ASP. can be removed. Paste out part of the 26th line, the bracket position is wrong.
In addition, the landlord posted as in if (OK) {} code missing part of it. The For loop is incomplete.
Copy Code code as follows:
Usecodepage Property
Usecodepage:boolean [Read-write]
Language version: ActionScript 3.0
Player version: Flash player 9
A Boolean value that tells Flash Player which code page to use to interpret an external text file. When this property is set to False, Flash Player interprets the external text file using Unicode. (When you save these files, you must encode them using Unicode.) When this property is set to True, Flash player interprets the external text file using the traditional code page of the operating system that is running the player. The default value for Usecodepage is false.
Text that is loaded as an external file (using Flash.display.Loader.load (), Flash.net.URLLoader, Flash.net.URLStream, or XML classes) must have been saved in Unicode encoding format so Flash Player can recognize it as Unicode. To encode external files using Unicode, save these files in applications that support Unicode (for example, Notepad on Windows 2000).
If you are loading an external text file that is not in Unicode encoding format, you should set Usecodepage to true. In the first frame of the SWF file that will load the data, add the following code to the top of the list to make it the first line of code:
System.usecodepage = true; with this line of code, Flash Player uses the traditional code page of the operating system running Flash Player to interpret the external text. For English Windows operating systems, the code page is usually CP1252, and for Japanese operating systems, the code page is typically shift-jis. If you set Usecodepage to True, Flash Player 6 and later process text in the same way as Flash Player 5. (Flash Player 5 treats all text as text encoded by the traditional code page of the operating system that is running the player.) )
If you set Usecodepage to True, be aware that you must include the characters used in your external text file in the traditional code page of the operating system where the player is running, so that you can display text. For example, if you load an external text file that contains Chinese characters, those characters cannot be displayed on a system that uses the CP1252 code page because the code page does not include Chinese characters.
To ensure that users on all platforms can view external text files that are used in your SWF file, you should encode all external text files in Unicode and leave the usecodepage false setting unchanged. In this way, Flash Player 6 and later will interpret the text in Unicode.