首先需求把菜单全部导入,也可以用程序导入到mc。我这里只是写教程,所以只是随便画了个矩形有个效果而已。
不过需求留意的是,必须将单个菜单的坐标对齐到0,0;观看效果:
点击这里下载源文件
// Flash AS代码如下;
Stage.align = "TL";
//对其场景为左上角;
Stage.scaleMode = "noScale";
//控制动画不自动缩放;
function BoxCopy(MacMenuName, step, MenuXW, Max, scaleX, MenuX, MenuY) {
createEmptyMovieClip(MacMenuName, 1);
//依据函数参数创建对应的MovieClip;
for (var i = 0; i<Max; i++) {
MacMenuBoxNum = eval(MacMenuName).attachMovie(MacMenuName, "MacMenuBoxName"+i, i);
//依据函数参数给出的菜单个数逐一装载进入刚才创建的MovieClip中;
MacMenuBoxNum.Num.text = i+1;
//此句是用来测试函数的显示结果的;
MacMenuBoxNum.onRelease = function() {
trace(this);
};
//此项定义菜单在点击过后执行的程序;
MacMenuBoxNum.onEnterFrame = scaleBox;
//此句控制调用菜单所放的函数;
}
var MenuBoxHeight = eval(MacMenuName)._height;
onEnterFrame = function () {
MenuX = MenuX == null || MenuX == "" || MenuX == undefined ? 0 : MenuX;
MenuY = MenuY == null || MenuY == "" || MenuY == undefined ? 0 : MenuY;
for (var i = 0; i<Max; i++) {
var MacMenuBoxNum = eval(MacMenuName)["MacMenuBoxName"+i];
// 援用对象;
MacMenuBoxNum._x = eval(MacMenuName)["MacMenuBoxName"+(i-1)]._x+eval(MacMenuName)["MacMenuBoxName"+(i-1)]._width+MenuXW;
// 初始化菜单的陈列方式;
MacMenuBoxNum._y = eval(MacMenuName)._y-MacMenuBoxNum._height;
eval(MacMenuName)._x = (Stage.width-eval(MacMenuName)._width)/2+MenuX;
eval(MacMenuName)._y = MenuBoxHeight+MenuY;
// 控制菜单的坐标;
}
};
function scaleBox() {
MouseX = Math.abs(this._x+this._width/2+eval(MacMenuName)._x-_root._xmouse);
MouseY = Math.abs(this._y+eval(MacMenuName)._y-_root._ymouse);
//得到鼠标与菜单的距离;
&nbs