flash按鈕控制小球左右滾動的兩種寫法

[前言]
高手莫看,給初學者。
[步驟]
第一步:創建影片剪輯元件,畫個小球,拖到主場景中,實例名爲_mc
第二步:創建按鈕元件,畫一個按鈕,拖到主場景中,實例名爲_btn
第三步:在主場景中的第一幀上寫代碼:
var i:Number = 0;
_btn.onRelease = function() {
i++;
if (i%2 == 1) {
  _mc.onEnterFrame = function() {
   this._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 = 570) {
    this._x = -20;
   }
  };
}
};看看效果:
本文轉自:http://www.5uflash.com/flashjiaocheng/Flashyingyongkaifa/153.html
發佈了0 篇原創文章 · 獲贊 0 · 訪問量 1518
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章