MC连线缓动演示(as2.0)
"MC连线缓动演示(as2.0)"这篇Flash教程如果帮助了您,请记得分享给您身边的朋友,如果您有比"MC连线缓动演示(as2.0)"更好的教程请发布共享,帮助别人快乐自己!
先看效果:
flashas_net.rar
详细代码:
///============================= MC连线缓动演示 ===========================
///============================= JOHNNY ===========================
//copyright@www.flashas.net by johnny 2008.5.10
Stage.scaleMode = noScale;
var mytxtarray:Array = new Array("AS1.0", "AS2.0", "AS3.0", "AIR", "LITE", "FLEX", "RIA", "问答", "论坛", "原文件");
//复制10个MC到场景上并赋予其相关参数
for (var i:Number = 0; i<10; i++) {
_root.attachMovie("mc","mc"+i,i+1);
_root["mc"+i]._x = 30+40*i;
_root["mc"+i]._y = 100+30*Math.random(10)*i;
_root["mc"+i].mytxt.text = mytxtarray;
_root["mc"+i].onPress = function() {
m = false;
delete this.onEnterFrame;
startDrag(this);
getmc_x = this._x;
getmc_y = this._y;
}
_root["mc"+i].onRelease = function() {
m = true;
stopDrag();
this.onEnterFrame = function() {
if (m == true) {
this._x += ((getmc_x-this._x)*0.6)/0.35;
this._y += ((getmc_y-this._y)*0.6)/0.35; //二级缓动
} else {
delete this.onEnterFrame;
}
}
}
}
//画线连接各MC
_root.createEmptyMovieClip("line",0);
_root.line.onEnterFrame = function() {
this.clear();
this.lineStyle(1,0x000000,100);
this.moveTo(mc0._x,mc0._y);
for (var j:Number = 1; j<10; j++) {
this.lineTo(_root["mc"+j]._x,_root["mc"+j]._y);
}
}
源文件下载:///============================= JOHNNY ===========================
//copyright@www.flashas.net by johnny 2008.5.10
Stage.scaleMode = noScale;
var mytxtarray:Array = new Array("AS1.0", "AS2.0", "AS3.0", "AIR", "LITE", "FLEX", "RIA", "问答", "论坛", "原文件");
//复制10个MC到场景上并赋予其相关参数
for (var i:Number = 0; i<10; i++) {
_root.attachMovie("mc","mc"+i,i+1);
_root["mc"+i]._x = 30+40*i;
_root["mc"+i]._y = 100+30*Math.random(10)*i;
_root["mc"+i].mytxt.text = mytxtarray;
_root["mc"+i].onPress = function() {
m = false;
delete this.onEnterFrame;
startDrag(this);
getmc_x = this._x;
getmc_y = this._y;
}
_root["mc"+i].onRelease = function() {
m = true;
stopDrag();
this.onEnterFrame = function() {
if (m == true) {
this._x += ((getmc_x-this._x)*0.6)/0.35;
this._y += ((getmc_y-this._y)*0.6)/0.35; //二级缓动
} else {
delete this.onEnterFrame;
}
}
}
}
//画线连接各MC
_root.createEmptyMovieClip("line",0);
_root.line.onEnterFrame = function() {
this.clear();
this.lineStyle(1,0x000000,100);
this.moveTo(mc0._x,mc0._y);
for (var j:Number = 1; j<10; j++) {
this.lineTo(_root["mc"+j]._x,_root["mc"+j]._y);
}
}
flashas_net.rar
