3. view the text
View the body, that is, the server receives the ID number sent from the Flash end, queries the database based on the ID number, and returns the query result to the Flash end in XML format.
A. Passed XML
1. Request Message
<FILE> <ID> ID of the topic to be viewed </ID> </FILE>
2. Response Message
<FILE id = "id" title = "topic" author = "author" content = "content" reply = "reply content"> </FILE>
B. Flash end
1. Create ten buttons in the second frame scenario, the instance names are "filebtn1", "filebtn2", "filebtn3", "filebtn4", "filebtn5", "filebtn6", "filebtn7", "filebtn8", and "filebtn9" and "filebtn10 ". The placement position and display content 2 are shown.
2. Add the following statement to the Action Script panel of Button filebtn1:
On (release ){
FileXml1 = new XML (); file: // Note 1
FileElement1 = fileXml1.createElement ("FILE"); file: // comment 2
IdElement1 = fileXml1.createElement ("ID"); file: // comment 3
IdNode1 = fileXml1.createTextNode ("id ");
IdNode1.nodeValue = _ root. fileId1;
IdElement1.appendChild (idNode1); file: // comment 4
FileElement1.appendChild (idElement1 );
FileXml1.appendChild (fileElement1 );
_ Root. fileNowId = _ root. fileId1; file: // comment 5
FileRepley1 = new XML ();
FileRepley1.onLoad = onFileReply1; file: // Note 6
Function onFileReply1 (filesuccess1 ){
If (filesuccess1 ){
_ Root. filetxt = fileRepley1.firstChild. attributes. title + fileRepley1.firstChild. attributes. author + response. attributes. content + fileRepley1.firstChild. attributes. reply; file: // comment 7
_ Root. gotoAndPlay ("content ");
}
}
FileXml1.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley1); file: // comment 8
}
Note 1: Create an XML object.
NOTE 2: create a FILE Node object.
NOTE 3: Create an ID Node object.
Note 4: add the FILE Node object and ID Node object to the XML object respectively.
Note 5: Save the sent ID to the temporary variable.
Note 6: Set the onLoad response function.
Note 7: The results returned by the server are displayed.
Note 8: The sendAndLoad () function is used to send XML objects from Flash to the server and receive XML objects returned from the server.
3. Add the following statement to the Action Script panel of Button filebtn2:
On (release ){
FileXml2 = new XML ();
FileElement2 = fileXml2.createElement ("FILE ");
IdElement2 = fileXml2.createElement ("ID ");
IdNode2 = fileXml2.createTextNode ("id ");
IdNode2.nodeValue = _ root. fileId2;
IdElement2.appendChild (idNode2 );
FileElement2.appendChild (idElement2 );
FileXml2.appendChild (fileElement2 );
_ Root. fileNowId = _ root. fileId2;
FileRepley2 = new XML ();
FileRepley2.onLoad = onFileReply2;
Function onFileReply2 (filesuccess2 ){
If (filesuccess2 ){
_ Root. filetxt = fileRepley2.firstChild. attributes. title + fileRepley2.firstChild. attributes. author + fileRepley2.firstChild. attributes. content + fileRepley2.firstChild. attributes. reply;
_ Root. gotoAndPlay ("content ");
}
}
FileXml2.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley2 );
}
4. Add the following statement to the Action Script panel of Button filebtn3:
On (release ){
FileXml3 = new XML ();
FileElement3 = fileXml3.createElement ("FILE ");
IdElement3 = fileXml3.createElement ("ID ");
IdNode3 = fileXml3.createTextNode ("id ");
IdNode3.nodeValue = _ root. fileId3;
IdElement3.appendChild (idNode3 );
FileElement3.appendChild (idElement3 );
FileXml3.appendChild (fileElement3 );
_ Root. fileNowId = _ root. fileId3;
FileRepley3 = new XML ();
FileRepley3.onLoad = onFileReply3;
Function onFileReply3 (filesuccess3 ){
If (filesuccess3 ){
_ Root. filetxt = fileRepley3.firstChild. attributes. title + fileRepley3.firstChild. attributes. author + fileRepley3.firstChild. attributes. content + fileRepley3.firstChild. attributes. reply;
_ Root. gotoAndPlay ("content ");
}
}
FileXml3.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley3 );
}
5. Add the following statement to the Action Script panel of Button filebtn4:
On (release ){
FileXml4 = new XML ();
FileElement4 = fileXml4.createElement ("FILE ");
IdElement4 = fileXml4.createElement ("ID ");
IdNode4 = fileXml4.createTextNode ("id ");
IdNode4.nodeValue = _ root. fileId4;
IdElement4.appendChild (idNode4 );
FileElement4.appendChild (idElement4 );
FileXml4.appendChild (fileElement4 );
_ Root. fileNowId = _ root. fileId4;
FileRepley4 = new XML ();
FileRepley4.onLoad = onFileReply4;
Function onFileReply4 (filesuccess4 ){
If (filesuccess4 ){
_ Root. filetxt = fileRepley4.firstChild. attributes. title + fileRepley4.firstChild. attributes. author + fileRepley4.firstChild. attributes. content + fileRepley4.firstChild. attributes. reply;
_ Root. gotoAndPlay ("content ");
}
}
FileXml4.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley4 );
}
6. Add the following statement to the Action Script panel of Button filebtn5:
On (release ){
FileXml5 = new XML ();
FileElement5 = fileXml5.createElement ("FILE ");
IdElement5 = fileXml5.createElement ("ID ");
IdNode5 = fileXml5.createTextNode ("id ");
IdNode5.nodeValue = _ root. fileId5;
IdElement5.appendChild (idNode5 );
FileElement5.appendChild (idElement5 );
FileXml5.appendChild (fileElement5 );
_ Root. fileNowId = _ root. fileId5;
FileRepley5 = new XML ();
FileRepley5.onLoad = onFileReply5;
Function onFileReply5 (filesuccess5 ){
If (filesuccess5 ){
_ Root. filetxt = fileRepley5.firstChild. attributes. title + fileRepley5.firstChild. attributes. author + fileRepley5.firstChild. attributes. content + fileRepley5.firstChild. attributes. reply;
_ Root. gotoAndPlay ("content ");
}
}
FileXml5.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley5 );
}
7. Add the following statement to the Action Script panel of Button filebtn6:
On (release ){
FileXml6 = new XML ();
FileElement6 = fileXml6.createElement ("FILE ");
IdElement6 = fileXml6.createElement ("ID ");
IdNode6 = fileXml6.createTextNode ("id ");
IdNode6.nodeValue = _ root. fileId6;
IdElement6.appendChild (idNode6 );
FileElement6.appendChild (idElement6 );
FileXml6.appendChild (fileElement6 );
_ Root. fileNowId = _ root. fileId6;
FileRepley6 = new XML ();
FileRepley6.onLoad = onFileReply6;
Function onFileReply6 (filesuccess6 ){
If (filesuccess6 ){
_ Root. filetxt = fileRepley6.firstChild. attributes. title + fileRepley6.firstChild. attributes. author + fileRepley6.firstChild. attributes. content + fileRepley6.firstChild. attributes. reply;
_ Root. gotoAndPlay ("content ");
}
}
FileXml6.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley6 );
}
8. Add the following statement to the Action Script panel of Button filebtn7:
On (release ){
FileXml7 = new XML ();
FileElement7 = fileXml7.createElement ("FILE ");
IdElement7 = fileXml7.createElement ("ID ");
IdNode7 = fileXml7.createTextNode ("id ");
IdNode7.nodeValue = _ root. fileId7;
IdElement7.appendChild (idNode7 );
FileElement7.appendChild (idElement7 );
FileXml7.appendChild (fileElement7 );
_ Root. fileNowId = _ root. fileId7;
FileRepley7 = new XML ();
FileRepley7.onLoad = onFileReply7;
Function onFileReply7 (filesuccess7 ){
If (filesuccess7 ){
_ Root. filetxt = fileRepley7.firstChild. attributes. title + fileRepley7.firstChild. attributes. author + fileRepley7.firstChild. attributes. content + fileRepley7.firstChild. attributes. reply;
_ Root. gotoAndPlay ("content ");
}
}
FileXml7.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley7 );
}
9. Add the following statement to the Action Script panel of Button filebtn8:
On (release ){
FileXml8 = new XML ();
FileElement8 = fileXml8.createElement ("FILE ");
IdElement8 = fileXml8.createElement ("ID ");
IdNode8 = fileXml8.createTextNode ("id ");
IdNode8.nodeValue = _ root. fileId8;
IdElement8.appendChild (idNode8 );
FileElement8.appendChild (idElement8 );
FileXml8.appendChild (fileElement8 );
_ Root. fileNowId = _ root. fileId8;
FileRepley8 = new XML ();
FileRepley8.onLoad = onFileReply8;
Function onFileReply8 (filesuccess8 ){
If (filesuccess8 ){
_ Root. filetxt = fileRepley8.firstChild. attributes. title + fileRepley8.firstChild. attributes. author + fileRepley8.firstChild. attributes. content + fileRepley8.firstChild. attributes. reply;
_ Root. gotoAndPlay ("content ");
}
}
FileXml8.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley8 );
}
10. Add the following statement to the Action Script panel of Button filebtn9:
On (release ){
FileXml9 = new XML ();
FileElement9 = fileXml9.createElement ("FILE ");
IdElement9 = fileXml9.createElement ("ID ");
IdNode9 = fileXml9.createTextNode ("id ");
IdNode9.nodeValue = _ root. fileId9;
IdElement9.appendChild (idNode9 );
FileElement9.appendChild (idElement9 );
FileXml9.appendChild (fileElement9 );
_ Root. fileNowId = _ root. fileId9;
FileRepley9 = new XML ();
FileRepley9.onLoad = onFileReply9;
Function onFileReply9 (filesuccess9 ){
If (filesuccess9 ){
_ Root. filetxt = fileRepley9.firstChild. attributes. title + fileRepley9.firstChild. attributes. author + fileRepley9.firstChild. attributes. content + fileRepley9.firstChild. attributes. reply;
_ Root. gotoAndPlay ("content ");
}
}
FileXml9.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley9 );
}
11. Add the following statement to the Action Script panel of Button filebtn10:
On (release ){
FileXml10 = new XML ();
FileElement10 = fileXml10.createElement ("FILE ");
IdElement10 = fileXml10.createElement ("ID ");
IdNode10 = fileXml10.createTextNode ("id ");
IdNode10.nodeValue = _ root. fileId10;
IdElement10.appendChild (idNode10 );
FileElement10.appendChild (idElement10 );
FileXml10.appendChild (fileElement10 );
_ Root. fileNowId = _ root. fileId10;
FileRepley10 = new XML ();
FileRepley10.onLoad = onFileReply10;
Function onFileReply10 (filesuccess10 ){
If (filesuccess10 ){
_ Root. filetxt = fileRepley10.firstChild. attributes. title + fileRepley10.firstChild. attributes. author + fileRepley10.firstChild. attributes. content + fileRepley10.firstChild. attributes. reply;
_ Root. gotoAndPlay ("content ");
}
}
FileXml10.sendAndLoad ("http: // localhost/xmlbbs/file. asp", fileRepley10 );
}
12. Add a key frame to the third frame of the scenario and set the label of the frame to "content". Add the following statement on the Action Script Panel of the frame: stop ();
Use the text box tool to pull a text box in this frame scenario to display the body of the topic. The type is Dynamic type, and the var variable is set to "filetxt ".
C. Asp end
Create an Asp file, save it as file. asp, and add the following content:
<%
Set MyFileObject = Server. CreateObject ("Scripting. FileSystemObject") 'comment 1
Set MyTextFile = MyFileObject. CreateTextFile ("G: \ writing \ flashxmlbbs \ login. xml", 8, TRUE)
MyTextFile. WriteLine (Request. Form) 'comment 2
Set objDom = server. CreateObject ("microsoft. xmldom") 'comment 3
ObjDom. loadxml (Request. Form) 'comment 4
Set objid = objdom.doc umentElement. SelectSingleNode ("// FILE/ID") 'comment 5
Id = objid. text
'Judge
Set conn = Server. CreateObject ("ADODB. Connection") 'comment 6
Conn. open "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" & Server. MapPath ("/xmlbbs. mdb ")
Set rs = Server. CreateObject ("ADODB. Recordset ")
StrSql = "select * from FileInfo where id =" & id' comment 7
Rs. open strSql, conn, 1, 1
Title = ""
Author = ""
Content = ""
If not (rs. bof and rs. eof) then' comment 8
Id = rs ("id ")
Title = rs ("title ")
Author = rs ("author ")
Content = rs ("content ")
End if
'Process the reply separately.
Rs. close
Reply = ""
StrSql = "select * from FileInfo where fid =" & id' comment 9
Rs. open strSql, conn, 1, 1
Do while not rs. eof
Reply = reply & "" & rs ("content") 'comment 10
Rs. moveNext 'comment 11
Loop
Rs. close
Conn. close
'Back
Response. write ("<FILE id =" "& id &" title = "& title &" "author =" & author & "content = "& content &" reply = "& reply &" "> </FILE> ") 'comment 12
%>
Note 1: create a temporary file object.
NOTE 2: Write the XML string from the Flash end to a temporary file.
NOTE 3: Create an XML object.
Note 4: import the XML string sent from Flash to an XML object.
Note 5: Read the content of the // FILE/ID node in the XML object.
Note 6: Create An ADO connection for a database.
Note 7: Construct an SQL string and query the database based on the sent ID.
Note 8: if a qualified record exists, read the corresponding record.
Note 9: the query condition for the reply post is Fid, so you need to query the database again.
Note 10: Construct the query records into a string.
Note 11: the pointer of the record set is moved down one step.
Note 12: Construct an XML string and send it to the Flash end.