FLASH中的移动方法教程和实例集锦(适合新手)

欢迎转载,敬请注明来源--闪吧和作者---sxl001---QQ:285510591
在此只探讨用AS语句去控制移动的方法。FLASH中能够移动的物体一般是舞台上的电影实例(为节省篇幅以下简称为MC,并且其实例名为my_mc)。FLASH中物体的移动是在X轴(即水平)方向或Y轴(垂直)方向的运动。因此,通过控制mc属性中的_x与_y的值就可以达到使其运动的目的。
[1b]
[color="#f709f7"]一、匀速运动[/color]
[/1b]1、水平方向上的向右匀速运动
方法一:
主场景第1帧:var mx=5;//设定初始速度为5
主场景第2帧:my_mc._x+=mx;//名称为my_mc的电影实例以步幅5的速度向右移动,
主场景第3帧:gotoAndPlay(2);// 跳转到第二帧,再次激发my_mc电影实例以步幅5的速度向右移动后又会跳转到此帧,并再次激发运动,如此周而得始地激发,就达到了不断向右运动的目的.
(见实例匀速运动1_1_1)
[img]http://space.flash8.net/space/images/system/haveattach.gif[/img]
[url=http://space.flash8.net/bbs/attachment.php?aid=309849][1b]
[color="#0000ff"]匀速运动1_1_1.swf[/color]
[/1b][/url]
(2006-09-30 04:10:19 PM, Size: 2.06 kB, Downloads: 0)
[img]http://space.flash8.net/space/images/system/haveattach.gif[/img]
[url=http://space.flash8.net/bbs/attachment.php?aid=309850][1b]
[color="#0000ff"]匀速运动1_1_1.fla[/color]
[/1b][/url]
(2006-09-30 04:10:19 PM, Size: 13.5 kB, Downloads: 0)
方法二:
主场景第1帧:
var mx = 5;//设定初始速度为5
this.onEnterFrame = function() {
        my_mc._x += mx;//不断刷新my_mc的向右运动
};//方法一需要3帧才能运动,而此方法二只需要一帧就可以使其运动,这是主要区别
(见实例匀速运动1_1_2_1)
[img]http://space.flash8.net/space/images/system/haveattach.gif[/img]
[url=http://space.flash8.net/bbs/attachment.php?aid=309851][1b]
[color="#0000ff"]匀速运动1_1_2_1.swf[/color]
[/1b][/url]
(2006-09-30 04:11:23 PM, Size: 2.17 kB, Downloads: 0)
[img]http://space.flash8.net/space/images/system/haveattach.gif[/img]
[url=http://space.flash8.net/bbs/attachment.php?aid=309852][1b]
[color="#0000ff"]匀速运动1_1_2_1.fla[/color]
[/1b][/url]
(2006-09-30 04:11:23 PM, Size: 15.5 kB, Downloads: 0)
或者:
var mx = 5;//初始速度值为5
onEnterFrame = function () {
        my_mc._x += mx;
};//此方法三与方法二的区别在于,方法二中this.onEnterFrame中的this是指当前时间轴;而在此方法三中直接用onEnterFrame,并未用this时,就表示暗指当前时间轴
(见实例匀速运动1_1_2_2)
[img]http://space.flash8.net/space/images/system/haveattach.gif[/img]
[url=http://space.flash8.net/bbs/attachment.php?aid=309853][1b]
[color="#0000ff"]匀速运动1_1_2_2.swf[/color]
[/1b][/url]
(2006-09-30 04:12:23 PM, Size: 2.27 kB, Downloads: 0)
[img]http://space.flash8.net/space/images/system/haveattach.gif[/img]
[url=http://space.flash8.net/bbs/attachment.php?aid=309854][1b]
[color="#0000ff"]匀速运动1_1_2_2.fla[/color]
[/1b][/url]
(2006-09-30 04:12:23 PM, Size: 15.5 kB, Downloads: 0)
或者:
var mx = 5;//初始速度值5
my_mc.onEnterFrame = function() {
        this._x += mx;
};//此处的my_mc.onEnterFrame指方法是加在my_mc上的.
(见实例匀速运动1_1_2_3)
[img]http://space.flash8.net/space/images/system/haveattach.gif[/img]
[url=http://space.flash8.net/bbs/attachment.php?aid=309855][1b]
[color="#0000ff"]匀速运动1_1_2_3.swf[/color]
[/1b][/url]
(2006-09-30 04:13:13 PM, Size: 2.25 kB, Downloads: 0)
[img]http://space.flash8.net/space/images/system/haveattach.gif[/img]
[url=http://space.flash8.net/bbs/attachment.php?aid=309856][1b]
[color="#0000ff"]匀速运动1_1_2_3.fla[/color]
[/1b][/url]
(2006-09-30 04:13:13 PM, Size: 11 kB, Downloads: 0)
方法三:
主场景my_mc上:
onClipEvent (load) {
        var mx = 5;//初始速度值5
}
onClipEvent (enterFrame) {
        _x += mx;//触发my_mc实例定义的动作是x轴坐标不断增值5。
}//(见实例匀速运动1_1_3_1)
[img]http://space.flash8.net/space/images/system/haveattach.gif[/img]
本文转自:http://www.5uflash.com/flashjiaocheng/Flashjichucaozuo/59.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值