当前位置: 首页 > 图文教程 > Flash动画 > Flash动画制作 > 用Flash AS简单制作可以任意拖动的四边形

Flash动画制作
相册类
Actionscript优化教程
用as来控制图片的曝光效果
如何将角度和坐标标准化
数组排序方法介绍
setInterval全面的介绍
attachMovie 函数的使用方法教程
flash action 详解(8)
AS的基本代码解释(3)
简单的检测鼠标是否有移动的类
FSCommand 用法详解
图片放大缩小移动类
flash中数组的妙用
如何使用Flash连接资料库
关于setInterval的应用
AS的基本代码解释(4)
动感地带学习专题(3)
动感地带学习专题(4)
动感地带学习专题(1)
动感地带学习专题(5)

Flash动画制作 中的 用Flash AS简单制作可以任意拖动的四边形


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-22   浏览: 94 ::
收藏到网摘: n/a

用Flash Actionscript简单制作可以任意拖动的四边形,是制作游戏的一个基础程序。

打开Flash,首先将属性改为30fps然后新建立一个组建laser,设置效果如下。

用Flash AS简单制作可以任意拖动的四边形

然后回到主场景,在第一帧内输入Action。

 laser_nodes = 4;
for (x=1; x<=laser_nodes; x++) {
    node = _root.attachMovie("laser", "laser_"+x, x, {_x:Math.random()*460+20, _y:Math.random()*310+20});
    node.onPress = function() {
        startDrag(this);
    };
    node.onRelease = function() {
        stopDrag();
    };
}
_root.createEmptyMovieClip("ray", _root.getNextHighestDepth());
ray.onEnterFrame = function() {
    this.clear();
    this.lineStyle(3, 0xff0000);
    this.moveTo(_root.laser_1._x, _root.laser_1._y);
    for (x=2; x<=laser_nodes; x++) {
        this.lineTo(_root["laser_"+x]._x, _root["laser_"+x]._y);
    }
    this.lineTo(_root.laser_1._x, _root.laser_1._y);
};

你可以修改上面的参数,比如laser_nodes = 其它数,就可以看到其它效果了!

最终演示效果。

看不到动画效果的朋友可以去这里观看:http://bbs.ruanchen.com/"http://bbs.ruanchen.com/" style="color: #000">点击下载源文件