发新话题
打印

[求救] 控制电影剪辑

控制电影剪辑

以下是小弟做的一个SWF,在我原代码的基础上,要怎样才能令按钮按下去之后,MC出现相应的变化(比如我点击mc1,我按放大,mc1就放大,点击mc2,我按放大,mc2放大.也就是按钮控制mc)

附件

放大缩小旋转.swf (2.14 KB)

2008-6-15 10:04, 下载次数: 63

放大缩小旋转.fla (91.5 KB)

2008-6-15 10:04, 下载次数: 34

TOP

复制内容到剪贴板
代码:
for (var i = 1; i<=2; i++) {
        _root["mc"+i].onPress = function() {
                this.swapDepths(_root.getNextHighestDepth());
                this.startDrag();
        };
        _root["mc"+i].onRelease = function() {
                this.stopDrag();
        };
}
menu1.onRelease = function() {
        for (i=1; i<3; i++) {
                _root["mc"+i]._rotation += 5;
                _root["mc"+i]._rotation += 5;
        }
};
menu2.onRelease = function() {
        for (i=1; i<3; i++) {
                _root["mc"+i]._rotation -= 5;
                _root["mc"+i]._rotation -= 5;
        }
};
menu3.onRelease = function() {
        for (i=1; i<3; i++) {
                _root["mc"+i]._xscale += 5;
                _root["mc"+i]._yscale += 5;
        }
};
menu4.onRelease = function() {
        for (i=1; i<3; i++) {
                _root["mc"+i]._xscale -= 5;
                _root["mc"+i]._yscale -= 5;
        }
};

TOP

也可以把代码简化为:
复制内容到剪贴板
代码:
function handlerFunc(_str:String, _p:Number) {
        mc1[_str] += _p, mc2[_str] += _p;
}
menu1.onRelease = function() {
        handlerFunc("_rotation", 5);
};
menu2.onRelease = function() {
        handlerFunc("_rotation", -5);
};
menu3.onRelease = function() {
        handlerFunc("_xscale", 5);
        handlerFunc("_yscale", 5);
};
menu4.onRelease = function() {
        handlerFunc("_xscale", -5);
        handlerFunc("_yscale", -5);
};

TOP

先Thanks~!小试下

TOP

先Thanks~!小试下

TOP

按钮好像同时控制两个mc,麻烦能不能在改进,使我点击mc1时就只是控制mc1,而点击mc2时就只控制mc2

TOP

复制内容到剪贴板
代码:
var now_mc:MovieClip = mc1;
mc1.onPress = mc2.onPress=function () {
now_mc = this;
this.swapDepths(this._parent.getNextHighestDepth());
this.onMouseUp = function() {
  this.stopDrag();
  delete this.onMouseUp;
};
};
function handlerFunc(_str:String, _p:Number) {
now_mc[_str] += _p;
}
menu1.onRelease = function() {
handlerFunc("_rotation", 5);
};
menu2.onRelease = function() {
handlerFunc("_rotation", -5);
};
menu3.onRelease = function() {
handlerFunc("_xscale", 5);
handlerFunc("_yscale", 5);
};
menu4.onRelease = function() {
handlerFunc("_xscale", -5);
handlerFunc("_yscale", -5);
};

附件

a.fla (48 KB)

2008-6-15 11:24, 下载次数: 43

a.swf (2.19 KB)

2008-6-15 11:24, 下载次数: 53

TOP

还有两个问题,怎么才可以让他们动起来,现在可以分别控制了,但是我还想可以拉动mc1和mc2,还有就是当缩放到一定程度的时候,缩放怎么变成了放大??怎样解决这个问题???再次麻烦了~!

TOP

请自己举一反三,多动手,少动口吧。

TOP

  版主的代码写的很详细了,建议楼主多看,多读,多练。
别人只能提供你解决问题的方法和途径,具体实现还是要靠自己的。

TOP

这个关键是路径问题吧,哈,楼主把“讨厌”惹毛了。。。

TOP

TOP

发新话题