XML section
Copy codeThe Code is as follows: <? Xml version = "1.0" encoding = "UTF-8"?>
<Li>
<Id>
<Pp> 1. What is the website of the 114 Yellow Pages Guigang station in China? </Pp>
<Aa> www.gg114chn.com </aa>
<Aa> gg.114chn.com </aa>
<Aa> www.114chn.com </aa>
<Aa> www.114.com </aa>
</Id>
<Id>
<Pp> 2. What is the contact phone number for the yellow pages of China 114? </Pp>
<Aa> 0775-4320568 </aa>
<Aa> 0775-4553709 </aa>
<Aa> 0775-4563709 </aa>
<Aa> 114 </aa>
</Id>
<Id>
<Pp> 3. China's 114 Yellow Pages Guigang operation center customer service QQ? </Pp>
<Aa> 10000 </aa>
<Aa> 380463801 </aa>
<Aa> 1015651717 </aa>
<Aa> 854512401 </aa>
</Id>
<Id>
<Pp> 4. What is China's 114 Yellow Pages company? </Pp>
<Aa> China Mobile </aa>
<Aa> China Telecom </aa>
<Aa> China phone no. 114, </aa>
<Aa> Beijing internet star culture communication Co., Ltd. </aa>
</Id>
</Li>
AS3 class-myform, which is placed in a myfirst package. Generate a form mainly composed of ComboBox component groups,Copy codeThe Code is as follows: package myfirst {
Import flash. display. Sprite;
Import flash. events .*;
Import flash.net .*;
Import flash. text. TextField;
Import flash. text. TextFieldType;
Import fl. data. DataProvider;
Import fl. controls. Button;
Import fl. controls. ComboBox;
Import fl. controls. SelectableList;
Import flash. system. System;
Public class myform extends Sprite {
System. useCodePage = true;
Var a_form: String = "";
Var a_num: int;
Var a_array: Array = new Array ();
Public function myform (): void {
Var loader: URLLoader = new URLLoader;
ConfigureListeners (loader );
Var request: URLRequest = new URLRequest ("pa. xml ");
Try {
Loader. load (request );
} Catch (error: Error ){
Trace ("Unable to load requested document .");
}
}
Private function configureListeners (dispatcher: IEventDispatcher): void {
Dispatcher. addEventListener (Event. COMPLETE, completeHandler );
}
Private function completeHandler (event: Event): void {
XML. ignoreProcessingInstructions = true;
Var loader: URLLoader=URLLoader(event.tar get );
Var myxml: XML = XML (loader. data. toString ());
A_num = myxml. id. pp. length ();
For (var I: int = 0; I <= a_num-1; I ++ ){
Var p_text: TextField = new TextField ();
P_text.text = myxml. id [I]. pp;
P_text.width = 250;
P_text.y = I * 50;
AddChild (p_text );
Var mycombobox: ComboBox = new ComboBox ();
Mycombobox. dropdownWidth = 180;
Mycombobox. move (20, 20 + I * 50 );
Mycombobox. prompt = "select answer ";
Mycombobox. addEventListener (Event. CHANGE, cardSelected );
AddChild (mycombobox );
For (var j: int = 0; j <= 3; j ++ ){
Mycombobox. addItem ({label: myxml. id [I]. aa [j]});
}
}
}
Private function cardSelected (event: Event): void {
Var cb: ComboBox = event. currentTarget as ComboBox;
Var cbindex: int = getChildIndex (cb)/2;
Var aa: int = cb. selectedIndex;
A_array [cbindex] = (String (aa ));
}
Public function mm (event: Event): void {
For (var k: int = 0; k <= a_num-1; k ++ ){
A_form + = String (a_array [k]);
}
Trace (a_form );
}
}
}
Another class url_asp, which is also placed in the myfirst package, is mainly used to connect ASP files.Copy codeThe Code is as follows: package myfirst {
Import flash. display. Sprite;
Import flash. events .*;
Import flash.net .*;
Import flash. text. TextField;
Import flash. text. TextFieldType;
Import fl. controls. Button;
Import fl. controls. TextInput;
Import flash. system. System;
Public class url_asp extends Sprite {
Public function url_asp (){
System. useCodePage = true;
Var form_name: TextField = new TextField ();
Var form_tel: TextField = new TextField ();
Form_name.text = "name :";
Form_tel.text = "Tel :";
Form_name.x = 100;
Form_name.y = 350;
Form_tel.x = 100;
Form_tel.y = 300;
AddChild (form_name );
AddChild (form_tel );
Var form_value = new myform ();
Form_value.x = 10;
Form_value.y = 10;
AddChild (form_value );
Var myname: String = "";
Var telephone: String = "";
Var a_form: String = "";
Var variables: URLVariables = new URLVariables ();
Var myrequest: URLRequest = new URLRequest ("save. asp ");
Var loader: URLLoader = new URLLoader ();
Var mybutton1: Button = new Button ();
Mybutton1.x = 180;
Mybutton1.y = 250;
Mybutton1.label = "Confirm answer ";
Mybutton1.addEventListener (MouseEvent. CLICK, form_value.mm );
AddChild (mybutton1 );
Var myname_input: TextInput = new TextInput ();
Myname_input.x = 180;
Myname_input.y = 350;
AddChild (myname_input );
Var telephone_input: TextInput = new TextInput ();
Telephone_input.x = 180;
Telephone_input.y = 300;
AddChild (telephone_input );
Var mybutton: Button = new Button ();
Mybutton. x = 180;
Mybutton. y = 400;
Mybutton. label = "submit information ";
AddChild (mybutton );
Mybutton. addEventListener (MouseEvent. CLICK, onclik );
Function onclik (event: Event): void {
Variables. myname = myname_input.text;
Variables. telephone = telephone_input.text;
Variables. a_form = form_value.a_form;
Trace (form_value.a_form );
Myrequest. data = variables;
Myrequest. method = URLRequestMethod. POST; // specify the URLRequest object as POST.
Loader. dataFormat = URLLoaderDataFormat. TEXT;
Loader. load (myrequest); // send data
}
}
}
}
Create a FLA file and write myfirst. url_asp as the document class.
ASP, three files.
--- Conn. asp ---
Asp file 1 Database ConnectionCopy codeThe Code is as follows: <%
Dim conn
Set conn = Server. CreateObject ("ADODB. Connection ")
Conn. Open "Driver = {Microsoft Access Driver (*. mdb)}; DBQ =" & server. mappath ("msg. mdb ")
%>
-- Save. asp ----
Asp file 2 save dataCopy codeThe Code is as follows: <! -- # Include file = conn. asp -->
<%
If request ("myname") = "" then
Response. Write ("no data ")
Response. End ()
Else
Myname = Request ("myname ")
Telephone = Request ("telephone ")
A_form = Request ("a_form ")
SQL = "Insert into data (myname, telephone, a_form) values ('" & myname & "', '" & telephone & "', '" & a_form &"')"
Conn. Execute (SQL)
Conn. close
Set conn = Nothing
Response. Write "OK"
End if
%>
---- List. asp ------
Asp file 3 view the answerCopy codeThe Code is as follows: <% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "65001" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
<Style type = "text/css">
<! --
Body {
Background-color: # B57202;
}
-->
</Style> <! -- # Include file = "conn. asp" -->
<Body>
<%
Dim rs_zl
Set rs_zl = server. createobject ("adodb. recordset ")
Rs_zl.open "select * from data", conn, 1, 1
Rs_zl.pagesize = 15
If request ("page") <> "then
Epage = cint (request ("page "))
If epage <1 then epage = 1
If epage> rs_zl.pagecount then epage = rs_zl.pagecount
Else
Epage = 1
End if
Rs_zl.absolutepage = epage
%>
<Table width = "750" border = "0" cellpadding = "2" cellspacing = "2">
<Tr bgcolor = "#666666" type = "codeph" text = "/codeph">
<Td> ID </td>
<Td> name </td>
<Td> phone number </td>
<Td> answer </td>
<Td> </td>
</Tr>
<%
For I = 0 to rs_zl.pagesize-1
If rs_zl.eof then exit
%>
<Tr bgcolor = "#666666" type = "codeph" text = "/codeph">
<Td> <% = rs_zl ("id") %> </td>
<Td> <% = rs_zl ("myname") %> </td>
<Td> <% = rs_zl ("telephone") %> </td>
<Td> <% = rs_zl ("a_form") %> </td>
<Td> </td>
</Tr>
<%
Rs_zl.movenext
Next
%>
</Table>
& Lt; table width = "530" & gt;
<Tr>
<Td width = "124" height = "38"> </td>
& Lt; td width = "259" & gt;
<P align = "center">
<A href = "list. asp"> homepage </a>
<A href = "list. asp? Page = <% = epage-1 %> "> previous page </a>
<A href = "list. asp? Page = <% = epage + 1%> "> next page </a>
<A href = "list. asp? Page = <% = rs_zl.pagecount %> "> last page </a>
</P>
<P align = "center"> page <% = epage %> <% = rs_zl.pagecount %> </p>
</Td>
<Td width = "131"> </td>
</Tr>
</Table>
<%
Rs_zl.close
Set rs_zl = nothing
Conn. close ()
%>
</Body>
</Html>