发新话题
打印

[求救] 用FOR怎么简化下面这段AS?

用FOR怎么简化下面这段AS?

我好象哪没转过弯来,思路是用变量来记录前一MC的坐标,但搞了半天好象也没搞对,来求教了
复制内容到剪贴板
代码:
a1.onPress = function() {
startDrag(this);
this.swapDepths(getNextHighestDepth());
};
a2.onPress = function() {
startDrag(this);
this.swapDepths(getNextHighestDepth());
};
a1.onRelease = function() {
stopDrag();
if (a2.hitTest(a1)) {
a1._x = a2._x;
a1._y = a2._y;
}
};
a2.onRelease = function() {
stopDrag();
if (a1.hitTest(a2)) {
a2._x = a1._x;
a2._y = a1._y;
}
};
[ 本帖最后由 iswaraj 于 2008-6-30 20:25 编辑 ]

附件

test.fla (46.5 KB)

2008-6-30 20:25, 下载次数: 14

Say No to anit-compiler !

TOP

只有两个元件,不需要for
复制内容到剪贴板
代码:
a1.onPress = a2.onPress=function () {
        this.startDrag();
        this.swapDepths(getNextHighestDepth());
};
a1.onRelease = a2.onRelease=function () {
        this.stopDrag();
        var _obj:Object = this == a1 ? a2 : a1;
        if (this.hitTest(_obj)) {
                this._x=_obj._x, this._y=_obj._y;
        }
};

TOP


var _obj:Object = this == a1 ? a2 : a1;
这句何解?(_obj=如果this==a1则_obj=a2否则_obj=a1?是这样吧)


如果用FOR上面这句就不能用了,用FOR该怎么写?

[ 本帖最后由 iswaraj 于 2008-6-30 21:36 编辑 ]
Say No to anit-compiler !

TOP

发新话题