5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:好人村
性别:先生
最后登录:2012-08-07
http://jh7086.5d.cn/
大坏人
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2007/11/22 | Tween1.0.as 简陋的缓动类AS1.0版本
类别(Flash习作)
|
评论
(1)
|
阅读(117)
|
发表于 23:29
//Tween类AS1.0版本
/*用例:
#include "Tween1.0.as"
var myTween=new Tween();
myTween.addTween(MC1,"_x",func1,0,200);
function func1(obj){
obj._x+=5;
}
myTween.addTween(MC2,"_alpha",func2,100,0);
function func2(obj){
obj._alpha-=5;
}
*/
function Tween() {
_global.Tween_intervalID1 = null;
_global.Tween_instance=this;
this.running = false;
this.list = new Array();
}
Tween.prototype.addTween = function(obj, prop, func, begin, finish) {
obj[prop] = begin;
this.list.push({obj:obj, prop:prop, func:func, begin:begin, finish:finish});
if (!this.running) {
this.start();
}
};
Tween.prototype.start = function() {
_global.Tween_intervalID1 = setInterval(function () {
_global.Tween_instance.run();
updateAfterEvent();
}, 0);
this.running = true;
};
Tween.prototype.run = function() {
if (this.list.length>0) {
var obj, prop, func, begin, finish;
for (var i in this.list) {
obj = this.list[i].obj;
prop = this.list[i].prop;
func = this.list[i].func;
begin = this.list[i].begin;
finish = this.list[i].finish;
//
func(obj);
if (obj[prop]>=finish) {
obj[prop] = finish;
this.list.splice(i, 1);
}
}
} else {
this.stop();
}
};
Tween.prototype.stop = function() {
clearInterval(_global.Tween_intervalID1);
_global.Tween_intervalID1 = null;
this.running = false;
};
3
评论
Comments
日志分类
首页
[163]
Flash习作
[85]
Flash进修
[33]
Flash推荐
[16]
Flash涂鸦
[4]
听~音乐
[9]
我滴地盘er
[16]