• 教你简单制作鼠标随意转动的立方体

    动画的制作步骤如下:

    1、 准备6张400*400 JPEG格式图片,作为立方体的六个侧面图片;

    2、 打开FLASH软件,设置舞台尺寸为870*650,把准备好的6张400*400图片导入到库里。

    (注:一定要是 ActionScript 2.0, 因为3.0不支持)

    3、 把库里的6张400*400图片重新命名,依次为:image0 image1 image2 image3 image4 image5 。

    4、 鼠标右键放在库里重新命名为image0的图片上,点击鼠标右键,在出现的待选项目里,把鼠标放在 链接 项目上,点击鼠标左键,出现如下提示:效果图如下


    在“为ActionScript”前面的框里点击,出现绿色的对号,如图所示。然后点确定。

    return (a.y > b.y == c.x > a.x);

    } // end if

    var _loc5 = c.x - a.x;

    if (!_loc5)

    {

    return (a.y > c.y == b.x < a.x);
    } // end if

    return ((b.y - a.y) / _loc4 < (c.y - a.y) / _loc5 != (a.x < b.x == a.x > c.x));

    } // End of the function

    Stage.scaleMode = "noScale";

    var rotations = {x: 0, y: 0, z: 0};

    var boxPoints = [{x: -100, y: -100, z: -100}, {x: 200, y: 200, z: -100}, {x: -100, y: 200, z: -100}, {x: -100, y: -100, z: 200}, {x: 200, y: -100, z: 200}, {x: 200, y: 200, z: 200}];

    this.createEmptyMovieClip("theScene", 1);

    theScene._x = theScene._y = 200;

    createImages();

    theScene.onEnterFrame = function ()

    {

    rotations.x = rotations.x - this._ymouse / 2000;

    rotations.y = rotations.y + this._xmouse / 2000;

    var _loc2 = pointsTransform(boxPoints, rotations);

    movieClip3PointTransform(this.image0, _loc2[2], _loc2[0], _loc2[3]);

    movieClip3PointTransform(this.image1, _loc2[5], _loc2[1], _loc2[2]);

    movieClip3PointTransform(this.image2, _loc2[0], _loc2[2], _loc2[1]);

    movieClip3PointTransform(this.image3, _loc2[4], _loc2[3], _loc2[0]);

    movieClip3PointTransform(this.image4, _loc2[3], _loc2[4], _loc2[5]);

    movieClip3PointTransform(this.image5, _loc2[1], _loc2[5], _loc2[4]);

    };

    注:1、以上红色部分里的数值代表图片的大小,就是说400*400的图片,就是这样的设置, 如果是200*200的图片,把数值200改成100就行啦。

    2、以上紫色部分里的数值代表旋转的速度,数值越大旋转越慢,反之就快,根据个人爱好任意设定。

    6、 返回场景 把名字为“语句”的影片剪辑拖入舞台,

    7、 Ctrl+回车键测试影片,OK

    其余的5张400*400图片也做同样处理。

    5、 新建一个名字为“语句”的影片剪辑,在第一帧添加动作代码如下:

    function createImages()

    {

    var _loc1 = 6;

    while (_loc1--)

    {

    theScene.createEmptyMovieClip("image" + _loc1, _loc1);

    theScene["image" + _loc1].createEmptyMovieClip("contents", _loc1);

    theScene["image" + _loc1].contents.attachBitmap(flash.display.BitmapData.loadBitmap("image" + _loc1), 1, false, true);

    } // end while

    } // End of the function

    function pointsTransform(points, rotations)

    {

    var _loc19 = new Array();

    var _loc11 = Math.sin(rotations.x);

    var _loc9 = Math.cos(rotations.x);

    var _loc13 = Math.sin(rotations.y);

    var _loc10 = Math.cos(rotations.y);

    var _loc14 = Math.sin(rotations.z);

    var _loc12 = Math.cos(rotations.z);

    var _loc7;

    var _loc8;

    var _loc5;

    var _loc3;

    var _loc4;

    var _loc2;

    var _loc20;

    var _loc15;

    var _loc16;

    var _loc1 = points.length;

    while (_loc1--)

    {

    _loc7 = points[_loc1].x;

    _loc8 = points[_loc1].y;

    _loc5 = points[_loc1].z;

    _loc3 = _loc9 * _loc8 - _loc11 * _loc5;

    _loc4 = _loc11 * _loc8 + _loc9 * _loc5;

    _loc20 = _loc10 * _loc4 - _loc13 * _loc7;

    _loc2 = _loc13 * _loc4 + _loc10 * _loc7;

    _loc15 = _loc12 * _loc2 - _loc14 * _loc3;

    _loc16 = _loc14 * _loc2 + _loc12 * _loc3;

    _loc19[_loc1] = {x: _loc15, y: _loc16};

    } // end while

    return (_loc19);

    } // End of the function

    function movieClip3PointTransform(mc, a, b, c)

    {

    mc._visible = pointsIsVisible(a, b, c);

    if (!mc._visible)

    {

    return;

    } // end if

    var _loc1 = mc.transform.matrix;

    _loc1.tx = b.x;

    _loc1.ty = b.y;

    _loc1.a = (a.x - b.x) / mc.contents._width;

    _loc1.b = (a.y - b.y) / mc.contents._width;

    _loc1.c = (c.x - b.x) / mc.contents._height;

    _loc1.d = (c.y - b.y) / mc.contents._height;

    mc.transform.matrix = _loc1;

    } // End of the function

    function pointsIsVisible(a, b, c)

    {

    var _loc4 = b.x - a.x;

    if (!_loc4)

    {
    2010/6/17 21:09:02
举报不良信息

 

 大  小