DFdou's Blog Life is short,Be yourself.

1301/090

Flash-表单输入和提交Demo


原本是打算做好Y头留言板的表单输入框之后再写下这个东西的,结果她没找好头像,。。
so,i只好在修改好许愿板的Flash之后,从源文件扣了这个部分出来做Demo。
这块mc主要功能是接收用户输入,以及给后台文件发送数据,这里后台用的是php,
PS:点击头像可以进行头像的切换。
Fla源文件下载地址:http://dl.getdropbox.com/u/477487/flash/as2/form-input-submit.fla
有兴趣的可以看下主要代码部分:

//头像id
var headid = 0;
exit_btn.onRelease = function() {
	removeMovieClip(this._parent);
};
var wish_send:LoadVars = new LoadVars();
submit_btn.onRelease = function() {
	checkForm();
	if (checkForm() == true) {
		wish_send.w_name = name_txt.text;
		wish_send.w_content = content_txt.text;
		wish_send.w_title = title_txt.text;
		wish_send.w_headid=int(headid)+1;
		txt_infoshow.text="name:"+wish_send.w_name+"\n"+"content:"+wish_send.w_content+"\n"+"title:"+wish_send.w_title+"\n"+"headid:"+wish_send.w_headid;
		//wish_send.send("w_save.php", "_self", "POST");
		removeMovieClip(this._parent);
	}
};
reset_btn.onRelease = function() {
	//trace(this);
	this._parent.title_txt.text = "";
	this._parent.content_txt.text = "";
	this._parent.name_txt.text = "";
};
function checkForm():Boolean {
	if (title_txt.text.length == 0) {
		title_txt.text = "请输入标题";
		Selection.setFocus("title_txt");
		return false;
	}
	if (content_txt.text.length == 0) {
		content_txt.text = "请输入内容";
		Selection.setFocus("title_txt");
		return false;
	}
	if (name_txt.text.length == 0) {
		name_txt.text = "请输入名字";
		Selection.setFocus("name_txt");
		return false;
	}
	Selection.setFocus("submit_btn");
	return true;
}

头像选择部分的代码:

//一直在用的TweenLite类
import gs.TweenLite;
import gs.easing.*;
head_btn.onRollOver = function() {
	TweenLite.to(this,0.5,{_alpha:75});
};
head_btn.onRollOut = head_btn.onReleaseOutside=function () {
	TweenLite.to(this,0.5,{_alpha:100});
};
head_btn.onRelease = function() {
	for (var i:Number = 0; i<7; i++) {
                //让头像失去鼠标事件,不然在动画过程中会触发onRollOver等事件,mc会卡在路上,囧!
		TweenLite.to(this._parent["h"+i],0.15,{_x:65, _alpha:75, delay:i/8, onComplete: onFinishTween, onCompleteParams:[this._parent["h"+i]]});
		this._parent["h"+i].onRollOver = function() {
			TweenLite.to(this,0.3,{_alpha:100});
		};
		this._parent["h"+i].onRollOut = function() {
			TweenLite.to(this,0.3,{_alpha:75});
		};
		this._parent["h"+i].onRelease = function() {
			var headonid = int(this._name.substr(1))+1;
			this._parent.head_btn.gotoAndStop(headonid);
			this._parent._parent.headid = headonid-1;
			for (var i:Number = 0; i<7; i++) {
				this._parent["h"+i].enabled=false;
				TweenLite.to(this._parent["h"+i],0.15,{_x:-280, _alpha:0, delay:i/8});
				}
		};
	}
};
//动画结束后让mc重新获得鼠标事件
function onFinishTween(btnid,ddd) {
	btnid.enabled = true;
}

Some Related Posts

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

:zhuang :xizao :wuwu :wenhao :wc :touxiang :shuaya :shuajian :shengtian :paopao :no :meinv :maonv :loveu :leilei :kua :jrjr :dahan :chi :chaocai :byebye


CommentLuv Enabled

No trackbacks yet.