旋转的立方体相册制作 - xrzs000的日志 - 网易博客

来源:百度文库 编辑:神马文学网 时间:2024/06/28 10:54:02

旋转的立方体相册制作

疯狂PS 2008-10-10 09:25:07 阅读1061 评论0   字号: 订阅

                1.打开FLASH,新建650×400文档。

                  

                2.导入事先准备好的六张图片,点“文件”-"导入"-“导入到库”。          

                3.选择事先处理好的图片,然后依次导入。我用PS软件处理的图片大小为200×199。

                  

                4.导入后,然后打开库面板。

                  

               5.在导入的图片上击右键。选择“链接”。

               

              6.在弹出的对话框中,输入"image0"。并且勾选如下图所示的两个复选框。
               

              7.依照此方法,依次对其他五张图片进行设置。六张图片分别为  image0  image1  image2  image3 image4   image5
              8.在主场景图层1上绘制一个背景。颜色填充参考如下。

              
              10.选中第一帧在动作面板里输入如下代码:
              

 [Action in Frame 1]

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 _loc17 = new Array();

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

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

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

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

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

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

    var _loc16;

    var _loc15;

    var _loc3;

    var _loc5;

    var _loc4;

    var _loc6;

    var _loc18;

    var _loc14;

    var _loc13;

    var _loc1 = points.length;

    while (_loc1--)

    {

        _loc16 = points[_loc1].x;

        _loc15 = points[_loc1].y;

        _loc3 = points[_loc1].z;

        _loc5 = _loc12 * _loc15 - _loc10 * _loc3;

        _loc4 = _loc10 * _loc15 + _loc12 * _loc3;

        _loc18 = _loc11 * _loc4 - _loc8 * _loc16;

        _loc6 = _loc8 * _loc4 + _loc11 * _loc16;

        _loc14 = _loc9 * _loc6 - _loc7 * _loc5;

        _loc13 = _loc7 * _loc6 + _loc9 * _loc5;

        _loc17[_loc1] = {x: _loc14, y: _loc13};

    } // end while

    return (_loc17);

} // 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 _loc5 = b.x - a.x;

    if (!_loc5)

    {

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

    } // end if

    var _loc4 = c.x - a.x;

    if (!_loc4)

    {

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

    } // end if

    return ((b.y - a.y) / _loc5 < (c.y - a.y) / _loc4 != (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: 100, y: 100, z: -100}, {x: -100, y: 100, z: -100}, {x: -100, y: -100, z: 100}, {x: 100, y: -100, z: 100}, {x: 100, y: 100, z: 100}];

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]);

};