[此文来源于互联网,牛C网只负责收集整理]
[前言]
高手莫看,给初学者。
[步骤]
第一步:创建影片剪辑元件,画个小球,拖到主场景中,实例名为_mc
第二步:创建按钮元件,画一个按钮,拖到主场景中,实例名为_btn
第三步:在主场景中的第一帧上写代码:
var i:Number = 0;
_btn.onRelease = function() {
i  ;
if (i%2 == 1) {
  _mc.onEnterFrame = function() {
   this._x -= 10;
   if (this._x<=-20) {
    this._x = 570;
   }
  };
}
if (i%2 == 0) {
  _mc.onEnterFrame = function() {
   _mc._x  = 10;
   if (this._x>=570) {
    this._x = -20;
   }
  };
}
};
—————————————————或者———————————————————
_btn.onRelease = function() {
this.id = !this.id;
if (this.id) {
  _mc.onEnterFrame = function() {
   this._x -= 10;
   if (this._x <= -20) {
    this._x = 570;
   }
  };
}
if (!this.id) {
  _mc.onEnterFrame = function() {
   _mc._x  = 10;
   if (this._x >= 570) {
    this._x = -20;
   }
  };
}
};

看看效果:

        

            


作者:gdgzboy@牛C网
地址:http://www.niuc.net/post/1922/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!



评论(0) | 引用(0) | 阅读(406)
发表评论
昵称 [注册]
密码 游客无需密码
网址
电邮
打开HTML 打开UBB 打开表情 隐藏 记住我