First, ASP reads the ACCESS database.
CopyCode The Code is as follows: <% @ Language = "VBScript" @ codePage = "65001" %>
<%
'Enable explicit variable Declaration
Option explicit
'Set the output type
Response. contenttype = "text/XML"
'Define three variables: conn (connection object), connstr (connectionstring), and SQL (an SQL statement)
Dim Conn, connstr, RS, SQL, I
'Define the connectionstring Value
I = 1
Connstr = "provider = Microsoft. Jet. oledb.4.0; Data Source =" & server. mappath ("test. mdb ")&";"
'Create a server connection object
Set conn = server. Createobject ("ADODB. Connection ")
'Create a DataSet object
Set rs = server. Createobject ("ADODB. recordset ")
'Open the data connection
Conn. Open connstr
'The meaning is to retrieve the values of the first 100 song1name and dong1url fields in the ascending order of the ID field values in the word data table. The value is attached to a DataSet object and is treated as an attribute of the dataset.
SQL = "select Top 100 [song1name], [dong1url] from [test] Order by ID DESC"
'Both the cursor type and lock type are set to 1. This is a read-only action that can only forward, with the fastest read speed.
Rs. Open SQL, Conn, 1, 1
Response. Write ("<? XML version = '1. 0' encoding = 'utf-8'?> <Taosha network> ")
'Do while loop, condition loop to the last condition that meets the condition
Do while not Rs. EOF
'This is the modified part so that the output file can be recognized by the loadvars object in flash.
Response. write ("<song info> <song name>" & RS ("song1name") & "</song name> <address>" & RS ("dong1url ")) & "</address> </song information>"
'Move the record down
Rs. movenext
I = I + 1
'The loop method that echoes do while is the main loop body.
Loop
Response. Write ("</taosha> ")
'Close the DataSet object.
Rs. Close
'Close the database connection
Conn. Close
'Release dataset Resources
Set rs = nothing
'Release database connection resources
Set conn = nothing
%>
This part of Code reads the database.
Let's take a look at how to generate xml. In fact, it is in the output. Add the corresponding XML format. For example, <song information> and various tags. Note that each label must be closed.
The code for this XML. asp file is as follows:
next, let's take a look at how the flash is loaded?
it should be easy. copy Code the code is as follows: // define the component
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});
}< BR >};
var my_object: Object = new object ();
my_object.change = function (eventobj: object): void {
my_textarea.text + = eventobj.tar get. selecteditem. label + "\ n";
};
my_list.addeventlistener ("change", my_object);
In this way, the generated XML file is imported into the list. Data can be called through monitoring functions.
Learn this well. For background projects, such as photo albums and dynamicArticleManagement, player, etc.
When creating Flash files that require loading external files, you must pay special attention to the encoding problem.
First, note that in the same flash, do not appear twice: "system. usecodepage = true ";
The original meaning of this sentence is to load the external non-"Utf-8" format file encoding into the uft-8 format, and if you use twice, it will be wrong.
The general cooperation method is, when the external file is stored, to select the uft-8 encoding format, or gb2312 format. As for the detailed differences between the two types of codes, I am not very clear yet. I hope you can give me some suggestions.
I in ASP is meaningless. Can be removed. There is an error in the bracket position when the part of the 26th rows is pasted.
In addition, the Code in if (OK) {} in the as posted by the poster lacks some. The for loop is incomplete. Copy code The Code is as follows: usecodepage attribute
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 external text files. When this attribute is set to false, Flash Player uses Unicode to interpret external text files. (UNICODE must be used to encode these files .) When this attribute is set to true, Flash Player uses the traditional code page of the operating system that runs the player to interpret external text files. The default value of usecodepage is false.
Load as an external file (using flash. display. loader. load (), flash.net. urlloader, flash.net. urlstream or XML class) text must have been saved in Unicode encoding format, so that flash player can recognize it as Unicode. To use Unicode to encode external files, use Unicode Program (For example, "Notepad" on Windows 2000.
If the external text file to be loaded is not in Unicode encoding format, set usecodepage to true. In the first frame of the SWF file that will load data, add the following code at the beginning 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 external text. For an English Windows operating system, the code page is usually cp1252. For a Japanese operating system, the code page is usually shift-JIS. If usecodepage is set to true, Flash Player 6 and later processes the text in the same way as Flash Player 5. (Flash Player 5 regards all text as text encoded by the traditional code page of the operating system running the player .)
If usecodepage is set to true, note that the traditional code page of the operating system running the player must contain the characters used in your external text file to display the text. For example, if you load an external text file containing Chinese characters, these characters cannot be displayed on the system that uses the cp1252 code page because the code page does not contain Chinese characters.
To ensure that all users on the platform can view the external text files used in your SWF file, all external text files should be encoded in UNICODE, and the false setting of usecodepage should be kept unchanged. In this way, Flash Player 6 and later will interpret the text in Unicode.