本文章主要讲flash留言板制作以及提供flash留言板源文件和asp+flash留言板源码最终目的就是让你用flash制作留言板 好了,先来看看留言的页面图片吧.
现在来看flash文件里面的actionscript第一帧action
stop();
var loadLv:LoadVars = new LoadVars();
tijiao.onRelease = function() {
if (nichen_txt == "" || liouyan_txt.text == "") {
xianshi_txt.text = "呢称或留言内容不能为空";
} else {
loadLv.username = nichen_txt.text;
loadLv.word = liouyan_txt.text;
loadLv.sendAndLoad("http://127.0.0.1/liouyan.asp", loadLv, "post");
}
};
removeTip.onRelease = function() {
nichen_txt.text = "";
liouyan_txt.text = "";
};
xianshi.onRelease=function(){
gotoAndStop(2);
}
loadLv.onLoad = function(success:Boolean) {
if (success) {
nichen_txt.text = "";
liouyan_txt.text = "";
xianshi_txt.text = this.username+"说"+this.word;
} else {
trace("加载失败");
}
};
第一帧的代码主要是用来留言验证的我想你应该看得懂,我们现在来看第二帧的代码.
stop();
var maxnum:Number = 5;
var num:Number = 1;
prev_btn.enabled = false;
next_btn.enabled = true;
var userArray:Array = new Array();
var infoArray:Array = new Array();
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success:Boolean) {
if (success) {
var root:XMLNode = this.firstChild;
for (var i = 0; i<root.childNodes.length; i++) {
userArray.push(root.childNodes[i].firstChild.firstChild);
infoArray.push(root.childNodes[i].lastChild.firstChild);
}
for (var i = maxnum*(num-1); i<maxnum*num; i++) {
_root["myTextArea"+i%maxnum].text = "昵称"+userArray[i]+"发表了留言,内容为"+infoArray[i];
}
} else {
myTextArea.text = "error";
}
};
myXML.load("http://127.0.0.1/xmlxianshi.asp");
prev_btn.onRelease = function() {
num = num-1;
next_btn.enabled = true;
if (num>=0) {
for (var i = maxnum*(num-1); i<maxnum*num; i++) {
_root["myTextArea"+i%maxnum].text = "昵称"+userArray[i]+"发表了留言,内容为"+infoArray[i];
}
} else {
prev_btn.enabled = false;
}
};
next_btn.onRelease = function() {
num = num+1;
prev_btn.enabled = true;
if (maxnum*num<userArray.length) {
for (var i = maxnum*(num-1); i<maxnum*num; i++) {
_root["myTextArea"+i%maxnum].text = "昵称"+userArray[i]+"发表了留言,内容为"+infoArray[i];
}
} else if (maxnum*num>userArray.length) {
for(var j=0;j<5;j++){
_root["myTextArea"+j].text ="";
}
for (var i = maxnum*(num-1); i<userArray.length; i++) {
_root["myTextArea"+i%maxnum].text = "昵称"+userArray[i]+"发表了留言,内容为"+infoArray[i];
}
next_btn.enabled = false;
} else {
next_btn.enabled = false;
}
};
这里主要是分析xml 文件并把数据发给你asp文件进行保存到数据库