Flash中图片不停循环播放,可改变左右方向
- 浏览:6337
- |
- 更新:
- |
- 标签:flash
步骤/方法
- 导入图片(这里以8张图片为例,且例子中图片为临时绘制的矩形,实际中可导入自己想要的图片),每导入一张都将其转换为影片剪辑(图片上点右键-转换为元件-影片剪辑),共8个影片剪辑。(从图片1至图片8)
- 在图层1,将8个影片剪辑都放入场景,并将它们之间间隔的距离设置成相同,第1张图片与场景左边的距离与它们之间间隔的距离也相同。
- 从图片1开始,依次为每个影片剪辑都设置实例名称(属性-实例名称,依次为mc1、mc2、...、mc8)......
- 图层2,画一个矩形,长度比场景的宽度短一些,可以将左右两个按钮显现出来。
- 在图层2上设置遮罩
- 新建图层3,添加两个按钮进来,放在场景的左右两边。
- 本页面未经许可获取自百度经验
- 给两个按钮分别设置实例名称为:an1、an2
- 再新建图层4,在这一帧设置帧动作:
kk = mc8._x+mc8._width;
for (i=1; i<=8; i++) {
_root["mc"+i].onEnterFrame = function() {
this._x -= 5;
if (this._x+this._width<=0) {
this._x = kk-this._width;
}
};
_root["mc"+i].onRollOver = function() {
for (j=1; j<=8; j++) {
delete _root["mc"+j].onEnterFrame;
}
};
_root["mc"+i].onRollOut = function() {
for (i=1; i<=8; i++) {
_root["mc"+i].onEnterFrame = function() {
this._x -= 5;
if (this._x+this._width<=0) {
this._x = kk-this._width;
}
};
}
};
}
an1.onRollOver = function() {//向左的按钮动作
for (i=1; i<=8; i++) {
_root["mc"+i].onEnterFrame = function() {
this._x -= 5;
if (this._x+this._width<=0) {
this._x = kk-this._width;
}
};
_root["mc"+i].onRollOver = function() {
for (j=1; j<=8; j++) {
delete _root["mc"+j].onEnterFrame;
}
};
_root["mc"+i].onRollOut = function() {
for (i=1; i<=8; i++) {
_root["mc"+i].onEnterFrame = function() {
this._x -= 5;
if (this._x+this._width<=0) {
this._x = kk-this._width;
}
};
}
};
}
};
an2.onRollOver = function() {//向右的按钮动作
for (i=1; i<=8; i++) {
_root["mc"+i].onEnterFrame = function() {
this._x += 5;
if (this._x+this._width>=kk) {
this._x = 0-this._width;
}
};
_root["mc"+i].onRollOver = function() {
for (j=1; j<=8; j++) {
delete _root["mc"+j].onEnterFrame;
}
};
_root["mc"+i].onRollOut = function() {
for (i=1; i<=8; i++) {
_root["mc"+i].onEnterFrame = function() {
this._x += 5;
if (this._x+this._width>=kk) {
this._x = 0-this._width;
}
};
}
};
}
};END
经验内容仅供参考,如果您需解决具体问题(尤其法律、医学等领域),建议您详细咨询相关领域专业人士。
展开阅读全部

















