确切地说..flash是不可以直接与数据库连接的.只能是通过ASP(只是我比较了解ASP,也可以是其他的PHP/JSP等);
所以呢.首先,先在ASP里编写好连接数据库的语句
<%
dim cn
dim connstr
dim db
db="asp.mdb"
Set cn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
cn.Open connstr
%>
存储为cn.asp文件;
第二步;就编写一个读取数据库数据的ASP文件喽...
<!--#include file="cn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from class ",cn,3,3
for i=1 to rs.recordcount
if not rs.eof then
totalClass=totalClass&rs("Class")&","
totalLink=totalLink&rs("classlink")&","
rs.movenext()
end if
next
response.write ("flashClass="&totalClass&"&")
response.write ("flashLink="&totalLink&"&")
'注意这个写格式.多个参数得用&这个来连接.有些人会忽略到这一点.导致在flash不能写出数据来.
%> 将这个文件存储为:write.asp
第三步;回到flash那里来编写语句.把write.asp文件加载进来.
第一帧:
System.useCodepage=true;
var newload = new LoadVars();//如果不是很了解这个LoaVars,可以去查一下那个flash里面的帮助文档
newload.load("write.asp");
newload.onLoad = function(success) {
if (success) {
_root.gotoAndStop(2);//当文件被加载完成后,执行第二帧.
}
};
stop();//这里要注意.如果不用停止.假设文件还没有加载完就执行第二帧...而在第二帧是在flash里读取数据的.那就导致读不出数据
第二帧:
_root.name.text = newload.flashClass;//下面两句是读取数据的.
_root.link.text = newload.flashLink;
_root.bt._visible = false;//是一个影片的名字,里面放有一个动态文本bttext
//现在就把数据放到数组中去....
var aspclass = newload.flashClass;
var link = newload.flashLink;
var Aclass = new Array();
var Blink = new Array();
for (i=0; i<aspclass.length; i++) {
Aclass = aspclass.split(",", i);
Blink = link.split(",", i);
}
for (i=0; i<Aclass.length-1; i++) {
//for (i=1; i<6; i++) {
_root.bt.duplicateMovieClip("bt"+i, i);
_root["bt"+i]._y = i*30;
_root["bt"+i]._x = 5;
_root["bt"+i].url = Blink;
_root["bt"+i].bttext.text = Aclass;
_root["bt"+i].onRelease = function() {
_root.link2.text = this.url;
getURL("http://"+this.url,"_blank");
};
}
This blogger is recording some code samples,technical skill of java,.Net,javascript, css, html for myself use. All articles are coming from my own experience and my collections which are from internet world. If you find any material have copy right issue please leave a comment to me. I will delete it immediately. These articles are writing in English or Chinese. Hope these information can help other technical guys. Thanks for reading.
Subscribe to:
Post Comments (Atom)
-
If you get "This page calls for XML namespace http://richfaces.org/a4j declared with prefix a4j but no taglibrary exists for that names...
-
Method 1: import oracle.sql.*; public class JClob { String tableName = null; // String primaryKey = null; // String primaryValue = null; // ...
-
1.HTTP-binding(ServiceMix) 1.4 各组件间传递消息流的过程如下: 1. HttpClient : Http 客户端运行一个独立的 Java 客户端程序,通过其中的 URLConnection 类连接到 http://...
No comments:
Post a Comment