|
点击隐藏登陆框
艺术资讯艺术画廊艺术高考设计教程艺术图吧艺术百科互动家居品位生活美育社区艺术问答站长博客留言反馈

您当前的位置:主页>教程>Flash教程>

Flash初级教程:介绍两种按钮控制小球左右滚动的写法
时间:2007-10-01 Tag: 点击:

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

END

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
 匿名?
关于本站|免责声明|广告服务|网站地图|网站搜索|友情链接|联系我们

本站网址:www.arthd.com    如有意见和建议,请惠赐E-mail至 xxf1860@163.com

Copyright © 2006-2008 arthd.com     闽ICP备05019582号酷站目录,收录各类优秀网站