查看完整版本: 控制电影剪辑

闪客小多 2008-6-15 10:04

控制电影剪辑

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

终极讨厌 2008-6-15 10:40

[code]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;
        }
};[/code]

终极讨厌 2008-6-15 10:47

也可以把代码简化为:[code]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);
};[/code]

闪客小多 2008-6-15 10:51

先Thanks~!小试下

闪客小多 2008-6-15 10:54

先Thanks~!小试下

闪客小多 2008-6-15 11:02

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

终极讨厌 2008-6-15 11:24

[code]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);
};[/code]

闪客小多 2008-6-15 17:47

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

终极讨厌 2008-6-15 17:50

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

ufo2010 2008-6-19 10:49

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

ayewhy 2008-6-25 16:02

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

m_s_g 2008-7-3 20:11

:)
页: [1]
查看完整版本: 控制电影剪辑