company logo
advertisement for deep fried Twinkies


3D效果


高人做了这个效果:

http://www.adobe.com/jp/events/cs3_web_edition_tour/page6.html

一看都是日文,没有原文件好像,于是有人送上了关于这个效果

http://hengtian.nyist.net/flash/show.php?id=33458

并附上AS。

function move()
{
       var _l5 = this.x * cosy - this.z * siny;
       var _l3 = this.z * cosy + this.x * siny;
       var _l4 = this.y * cosx - _l3 * sinx;
       var _l6 = _l3 * cosx + this.y * sinx;
       this.x = _l5;
       this.y = _l4;
       this.z = _l6;
       var _l2 = fl / (fl + this.z + zc);
       this._x = this.x * _l2 + xc;
       this._y = this.y * _l2 + yc;
       this._xscale = this._yscale = _l2 * 100;
       this.swapDepths(1000000 - (this.z + Math.random()) * 1000);
       this._rotation = this._rotation + this.vr;
} // End of the function
xc = 270;
yc = 200;
zc = 200;
fl = 250;
spacing = 75;
count = 0;
ya = 0;
cosy = Math.cos(ya);
siny = Math.sin(ya);
xa = 0;
cosx = Math.cos(xa);
sinx = Math.sin(xa);
var i = 0;
while (i < 50)
{
       ball = attachMovie("ball", "ball" + i, i);
       ball.gotoAndStop(i % 4 + 1);
       ball.x = (Math.random() * 4 - 2) * spacing;
       ball.y = (Math.random() * 4 - 2) * spacing;
       ball.z = (Math.random() * 4 - 2) * spacing;
       ball._rotation = Math.random() * 360;
       ball.vr = Math.random() * 10 - 5;
       ball.onEnterFrame = move;
       i++;
} // end while
onEnterFrame = function ()
{
       ya = (_xmouse - 270) * 0.000500;
       cosy = Math.cos(ya);
       siny = Math.sin(ya);
       xa = (_ymouse - 200) * 0.000500;
       cosx = Math.cos(xa);
       sinx = Math.sin(xa);
};

做出效果如下:

http://lancaodui.kki.cn/3D小球.swf

这个是AS2的,注意.

///////////////////////////////////////////////////////////////////////////////////////////////

swapDepths(MovieClip.swapDepths 方法)

public swapDepths(target: Object) : Void

交换此影片剪辑与另一影片剪辑的堆栈或深度级别(Z 顺序),另一影片剪辑由

target 参数指定,或指定为当前占用由 target 参数指定的深度级别的影片剪辑。

两个影片剪辑必须具有相同的父级影片剪辑。交换影片剪辑的深度级别的作用是

将一个影片剪辑移到另一个影片剪辑的前面或后面。如果调用该方法时影片剪辑

正在补间,则补间会停止。

您可以通过创建子类来扩展 MovieClip 类的方法和事件处理函数。

可用性:ActionScript 1.0、Flash Player 5

参数

target:Object ― 此参数可以采用以下两种格式之一:

  • 一个数字,指定要将影片剪辑放置到的深度级别。
  • 一个指定影片剪辑实例的实例名称,应用本方法的影片剪辑将与该影片剪辑
  • 交换深度。两个影片剪辑必须具有相同的父级影片剪辑。

示例

下面的示例交换两个影片剪辑实例的堆叠顺序。在舞台上重叠名为 myMC1_mc

myMC2_mc 的两个影片剪辑实例,然后将下列脚本添加到父时间轴上:

myMC1_mc.onRelease = function() {
this.swapDepths(myMC2_mc);
};
myMC2_mc.onRelease = function() {
this.swapDepths(myMC1_mc);
};