当前位置: 首页 > 图文教程 > Flash动画 > ActionScript > Flash AS实例:制作切换菜单动画

ActionScript
Flash as入门(4):AS常用语句
Flash as入门(5):学习AS数组
Flash as入门(6):文本与字符串⒒
Flash AS3鼠标事件使用详解
网页中flash的trace方法输出数据
Flash as入门(11):拖动与碰撞检测
AS教程:随机显示数字
Flash AS文本字段的透明度alpha变换
AS教程:对场景和MC添加鼠标监听
AIR设置:transparent和systemChrome
Flash AS3教程:flash.text.TextField
AS教程:理解变量作用域修饰符(modifier)
ActionScript3.0中类间传值问题解决
ActionScript3.0中类的定义以及类属性
Flash AS3教程:类属性的属性
ActionScript3.0教程:变量
ActionScript3.0教程:方法
ActionScript3.0教程:类的枚举
简单认识Flash as面向对象编程
Flash AS2教程:影片剪辑

ActionScript 中的 Flash AS实例:制作切换菜单动画


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-30   浏览: 81 ::
收藏到网摘: n/a

先看看效果:


详细代码:


//AS2.0/////////QQ:31559783////////2010.01.11///////////////////////////////

var 设置 = {};

设置.数量 = 10;

设置.间距 = 150;

设置.比例 = 250;

设置.速度 = 4;

//////////////////////////////////////////////

var 中心MC = 0;

var 按 = false;

var 转 = false;

var H = Stage.height/2;

var W = Stage.width/2;

for (var i = 0; i<设置.数量+1; i++) {

var MC_mc = this.attachMovie("mc", "mc_"+this.getNextHighestDepth(), this.getNextHighestDepth());

if (i<设置.数量) {

MC_mc.txt.text = i+1;

MC_mc.hd = Math.PI*2/设置.数量*i;

MC_mc._x = W+Math.sin(MC_mc.hd)*设置.间距;

MC_mc._y = H+Math.cos(MC_mc.hd)*设置.间距;

} else {

MC_mc.txt.text = i+1;

MC_mc._x = W;

MC_mc._y = H;

MC_mc._xscale = 设置.比例;

MC_mc._yscale = 设置.比例;

中心MC = MC_mc;

}

MC_mc.onPress = function() {

if (中心MC != this && 按 == false) {

按 = true;

var ox = this._x;

var oy = this._y;

this.swapDepths(_root.getNextHighestDepth());

this.onEnterFrame = function() {

this._x += (W-this._x)/设置.速度;

this._y += (H-this._y)/设置.速度;

this._xscale += (设置.比例-this._xscale)/设置.速度;

this._yscale += (设置.比例-this._yscale)/设置.速度;

中心MC._x += (ox-中心MC._x)/设置.速度;

中心MC._y += (oy-中心MC._y)/设置.速度;

中心MC._xscale += (100-中心MC._xscale)/设置.速度;

中心MC._yscale += (100-中心MC._yscale)/设置.速度;

if (Math.abs(中心MC._x-ox) >> 0<=1 && Math.abs(中心MC._y-oy) >> 0<=1) {

中心MC._x = ox;

中心MC._y = oy;

this._x = W;

this._y = H;

中心MC = this;

按 = false;

delete this.onEnterFrame;

}

};

}

};

}
源文件附件:切换菜单.rar