现在再将这五个typo都转化为MC(在场景中按F8即可),我们给它们起名为MM-a1~MM-a5,并将随之产生的实例命名为a1~a5。给它们都分别加入AS——
onClipEvent (load) {
objnum = _name.slice(1, 2);
_parent.init3D(objNum);
}
onClipEvent (enterFrame) {
tb = this.getBounds(this);
valueA = Math.pow(_parent._xmouse - tb.xMin, 2);
valueB = Math.pow(_parent._ymouse - tb.yMax, 2);
distance = Math.sqrt(valueA + valueB) * 0.5;
if (distance <= 200) {
this._xscale = this._xscale + (((200 - distance) - this._xscale) * 0.1);
this._yscale = this._yscale + (((200 - distance) - this._yscale) * 0.1);
} else {
this._xscale = this._xscale + ((50 - this._xscale) * 0.1);
this._yscale = this._yscale + ((50 - this._yscale) * 0.1);
}
this.typo._x = _parent._ymouse * 0.1;
this.typo._y = this.typo._y + (((_parent._ymouse - this.typo._y) * 0.1) *
objNum);
_parent.move3D(objnum);
}
这段AS一开始会把实例名的一部分切下来,也就是a1,a2,a3…的序号1,2,3……。并将之传递给父级目录下的init3D这个函数。接着,在每一帧都计算鼠标与正方形左下角顶点的距离,将对MC进行动态的放缩。
现在对这五个加入了AS的影片实例a1~a5进行排序,分别将他们放在不同的层中,靠右边的层要高一点,因为它要压在其左边层的上方。排好层后再新建一层,加入如下AS——
function init3D(objnum) {
i = 1;
while (i<=4) {
this[("newName"+objnum)+i] = ("sq"+objnum)+i;
_root.createEmptyMovieClip(this[("newName"+objnum)+i], (objnum*10)+i);
i++;
}
}
function move3D(objnum) {
Xorigin = _x;
Yorigin = _y;
with (_root[("sq"+objnum)+"3"]) {
clear();
beginFill("0x"+colorData[2], 100);
MoveTo(Xorigin, Yorigin);
LineTo(this["a"+objnum].typo.xMaxdata, this["a"+objnum].typo.yMindata);
LineTo(this["a"+objnum].typo.xMaxdata, this["a"+objnum].typo.yMaxdata);
endFill();
}
with (_root[("sq"+objnum)+"4"]) {
clear();
colors = [15133171, 13421772];
alphas = [100, 100];
ratios = [0, 255];
matrix = {matrixType:"box", x:_root._xmouse, y:_root._xmouse, w:550, h:400,
r:(radian/180)*Math.PI};
beginGradientFill("linear", colors, alphas, ratios, matrix);
MoveTo(this["a"+objnum].typo.xMindata, this["a"+objnum].typo.yMindata);
LineTo(this["a"+objnum].typo.xMaxdata, this["a"+objnum].typo.yMindata);
LineTo(this["a"+objnum].typo.xMaxdata, this["a"+objnum].typo.yMaxdata);
LineTo(this["a"+objnum].typo.xMindata, this["a"+objnum].typo.yMaxdata);
endFill();
}
if (_root._ymouse<_y) {
_root[("sq"+objnum)+"2"].clear();
with (_root[("sq"+objnum)+"1"]) {
clear();
beginFill("0x"+colorData[0], 100);
MoveTo(Xorigin, Yorigin);
LineTo(this["a"+objnum].typo.xMindata, this["a"+objnum].typo.yMaxdata);
LineTo(this["a"+objnum].typo.xMaxdata, this["a"+objnum].typo.yMaxdata);
endFill();
}
} else if (_root._ymouse>=_y) {
_root[("sq"+objnum)+"1"].clear();
with (_root[("sq"+objnum)+"2"]) {
clear();
beginFill("0x"+colorData[1], 100);
MoveTo(Xorigin, Yorigin);
LineTo(this["a"+objnum].typo.xMaxdata, this["a"+objnum].typo.yMindata);
LineTo(this["a"+objnum].typo.xMindata, this["a"+objnum].typo.yMindata);
endFill();
}
}
}
colorData = ["333333", "999999", "666666"];
|