快速业务通道

画笔步骤录制

作者 佚名技术 来源 服务器技术 浏览 发布时间 2012-07-10


标题:画笔步骤录制
试题内容:做一个画笔,并记录下画笔的每一步都来,录制完后可以点击播放!其实数据存储编写方式多种多样,这里没有具体要求,通过这个练习也可以相互比较!
原文件:
//录制的过程中可以停止,进行其他的重放,重放完了回到刚才录制的中断处,继续点录制可以接着录,这里我就用5秒意思一下,不然30秒太长了。
点击浏览该文件
点击浏览该文件
http://www.Flash8.net/bbs/UploadFile/2005-7/20057191061553.swf
所有的代码如下:
import mx.controls.List;
import mx.controls.Button;
var inter;
var draw_statue = false;
var time = 0;
var round = 0;
var replay = false;
var _obj;
var This = this;
var temp_arr;
var temp = [];
var i = 0;
var hit_num;
var maxtime = 5;
createEmptyMovieClip("bgBoard", getNextHighestDepth());
with (bgBoard) {
lineStyle(0);
beginFill(0xffffff);
lineTo(350, 0);
lineTo(350, 300);
lineTo(0, 300);
endFill();
_x=30, _y=30;
}
createEmptyMovieClip("drawBoard", getNextHighestDepth());
function setUIObject() {
createClassObject(Button, "pr_btn", getNextHighestDepth(), {label:"录制", _x:400, _y:350});
createClassObject(Button, "del_btn", getNextHighestDepth(), {label:"删除", _x:400, _y:300});
createClassObject(List, "list", getNextHighestDepth(), {_x:400, _y:30, _height:250});
createTextField("statue", getNextHighestDepth(), 300, 350, 100, 20);
createTextField("myname", getNextHighestDepth(), 10, 350, 100, 20);
myname.text = "寒冰制造";
statue.text = "等待中。。。";
pr_btn.onPress = function() {
(!replay) ? ((this.label == "录制") ? (draw_statue=true, this.label="停止", statue.text="录制中。。。", timeRun(this)) : (clearInterval(_obj.mc.inter), clearInterval(inter), draw_statue=false, this.label="录制", statue.text="等待中。。。")) : null;
};
_obj = {};
_obj.mc = createEmptyMovieClip("r_run", getNextHighestDepth());
_obj.change = function(eventObj) {
hit_num = eventObj.target.selectedIndex;
clearInterval(inter);
statue.text = "重放中。。。";
pr_btn.label = "录制";
replay = true;
var This = this.mc;
This.clear();
This.lineStyle(0, 0xff0000);
This.i = 0;
temp_arr = eventObj.target.value;
drawBoard.clear();
This.moveTo(temp_arr[0].x, temp_arr[0].y);
clearInterval(This.inter);
This.inter = setInterval(function () {
if (++This.i if (temp_arr[This.i].d == "p") {
This.moveTo(temp_arr[This.i].x, temp_arr[This.i].y);
}
This.lineTo(temp_arr[This.i].x, temp_arr[This.i].y);
statue.text = "重放中。。。";
pr_btn.label == "录制";
} else {
clearInterval(This.inter);
replay = false;
This.clear();
if (temp.length>0) {
drawBoard.lineStyle(0, 0xff0000);
drawBoard.moveTo(temp[0].x, temp[0].y);
for (var j = 1; j if (temp[j].d == "p") {
drawBoard.moveTo(temp[j].x, temp[j].y);
}
drawBoard.lineTo(temp[j].x, temp[j].y);
}
}
statue.text = "等待中。。。";
pr_btn.label == "录制";
draw_statue=false;//加上了这个,应该就没问题了,变量太多容易遗漏。。
// timeRun(pr_btn);
}
}, 10);
};
list.addEventListener("change", _obj);
del_btn.onPress = function() {
list.removeItemAt(hit_num);
_obj.mc.clear();
clearInterval(_obj.mc.inter);
replay = false;
statue.text = "等待中。。。";
pr_btn.label == "录制";
};
}
function timeRun(u) {
inter = setInterval(function () {
time++;
statue.text = "录制中。。。"+time+"秒";
if (time>=maxtime) {
time = 0;
round++;
list.addItem({label:"第"+round+"次", data:temp});
u.label = "录制";
statue.text = "等待中。。。";
draw_statue = false;
drawBoard.clear();
temp = [];
onMouseMove = null;
clearInterval(inter);
}
}, 1000);
}
bgBoard.useHandCursor = false;
bgBoard.onPress = function() {
if (draw_statue) {
temp.push({x:_xmouse, y:_ymouse, d:"p"});
press = true;
drawBoard.lineStyle(0, 0xff0000);
drawBoard.moveTo(_xmouse, _ymouse);
}
onMouseMove = function () {
if (press and bgBoard.hitTest(_xmouse, _ymouse)) {
temp.push({x:_xmouse, y:_ymouse});
drawBoard.lineTo(_xmouse, _ymouse);
}
};
};
onMouseUp = function () {
onMouseMove = null;
press = false;
};
setUIObject();


凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号