XML part
Copy Code code as follows:
<?xml version= "1.0" encoding= "Utf-8"?>
<li>
<id>
<PP>1, China 114 Yellow Pages Guigang station URL is? </pp>
<aa>www.gg114chn.com</aa>
<aa>gg.114chn.com</aa>
<aa>www.114chn.com</aa>
<aa>www.114.com</aa>
</id>
<id>
What is the contact number of <pp>2, China 114 Yellow Pages? </pp>
<aa>0775-4320568</aa>
<aa>0775-4553709</aa>
<aa>0775-4563709</aa>
<aa>114</aa>
</id>
<id>
<PP>3, China 114 Yellow Pages Guigang Operation Center Customer service QQ is? </pp>
<aa>10000</aa>
<aa>380463801</aa>
<aa>1015651717</aa>
<aa>854512401</aa>
</id>
<id>
<pp>4, the head office of China's 114 yellow pages? </pp>
<aa> China Mobile </aa>
<aa> China Telecom </aa>
<aa> China No. 114th Code </aa>
<aa> Beijing internet Star Culture Communication Co., Ltd. </aa>
</id>
</li>
AS3 class-myform, put in a myfirst bag. Generates a form that is primarily composed of the ComboBox component Group,
Copy Code code 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.target);
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= "Choose the 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 of url_asp, also placed in the Myfirst package, is used primarily to connect ASP files
Copy Code code 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 the 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= "Submitting 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;//specifies that the URLRequest object is POST.
Loader.dataformat = Urlloaderdataformat.text;
Loader.load (myrequest);//Send data
}
}
}
}
Build a FLA, say document class to write myfirst.url_asp.
ASP part, three files.
---conn.asp---
ASP file 1 database connection
Copy Code code as follows:
<%
Dim Conn
Set conn=server.createobject ("ADODB. Connection ")
Conn. Open "Driver={microsoft Access Driver (*.mdb)};D bq=" & Server.MapPath ("Msg.mdb")
%>
--save.asp----
ASP file 2 Save data
Copy Code code 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 answer
Copy Code code 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 ">
<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" >
<td>ID</td>
<td> name </td>
<td> Tel </td>
<td> Answers </td>
<td> </td>
</tr>
<%
For I=0 to Rs_zl.pagesize-1
If Rs_zl.eof then exit for
%>
<tr bgcolor= "#666666" >
<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>
<table width= "530" >
<tr>
<TD width= "124" height= "> </td>"
<TD width= "259" >
<p align= "center" >
<a href= "list.asp" > Home </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 </a>
</p>
<p align= "Center" > now is <%=epage%> page altogether has <%=rs_zl.pagecount%> page </p>
</td>
<TD width= "131" > </td>
</tr>
</table>
<%
Rs_zl.close
Set Rs_zl = Nothing
Conn.close ()
%>
</body>