当前位置:主页>AS 应用>文章内容
  • 按钮控制小球左右滚动的两种写法(基础篇)
  • 来源: 作者:qinz 2007-09-21 【
FlashAs作品发表>>我要投稿 | FlashAs讨论区>>AS论坛
Flash Media Server学习站>>www.FMScn.com


[前言]
高手莫看,给初学者。
[步骤]
第一步:创建影片剪辑元件,画个小球,拖到主场景中,实例名为_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;
   }
  };
}
};


看看效果:

 




上一篇:flash as : 纯AS旋转特效   下一篇:flash as : 一个飞翔菜单
  • 用户名:新注册) 密码: 匿名评论
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)
FLASH源文件

Copyright © 2006-2008 flashas.net All Rights Reserved.
网站内容咨询: admin#flashas.net (#为@) 联系QQ:40777822 浙ICP备06033001号
(本网站最佳浏览解析度为1024*768, 建议使用IE 6.0或以上版本浏览器。)