Flash初级教程:介绍两种按钮控制小球左右滚动的写法,Flash初级教程:介绍两种按钮控制小球左右滚动的写法
【 tulaoshi.com - Flash 】
[前言]
高手莫看,给初学者。
[步骤]
第一步:创建影片剪辑元件,画个小球,拖到主场景中,实例名为_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;
}
};
}
};
看看效果(用鼠标点击黑色按钮看看):
看不到动画效果的朋友请去这里观看:http://bbs.jcwcn.com/thread-117818-1-1.html
来源:http://www.tulaoshi.com/n/20160129/1486710.html
看过《Flash初级教程:介绍两种按钮控制小球左右滚动的写法》的人还看了以下文章 更多>>
如果您有什么好的建议或者疑问,可以联系我们。 商务合作QQ:3272218541;3282258740。商务合作微信:13319608704;13319603564。
加好友请备注机构名称。让我们一起学习、一起进步tulaoshi.com 版权所有 © 2019 All Rights Reserved. 湘ICP备19009391号-3
微信公众号