点击图标观看效果--伪3D旋转菜单:
代码:
import flash.geom.Point;
var total:Number = 11;
var center:Point = new Point(Stage.width/2, Stage.height/2);
var rx:Number = 180;
var ry:Number = 80;
var step:Number = 0;
var entity:MovieClip = _root.createEmptyMovieClip("entity", 10);
for (var i:Number = 0; i<total; i++) {
var image:MovieClip = entity.attachMovie("image1", "image"+i, i);
image.txt.text = i;
align(0);
rotate(image);
}
function rotate(mc:MovieClip):Void {
mc.onPress = function() {
if (_root._xmouse-center.x>0) {
var num:Number = 5;
} else {
var num:Number = -5;
}
this.onEnterFrame = function() {
align(num);
if (num>0 && this._x<center.x) {
delete this.onEnterFrame;
} else if (num<0 && this._x>center.x) {
delete this.onEnterFrame;
}
};
};
}
function align(num):Void {
var radian:Number = Math.PI/180;
for (var i:Number = 0; i<total; i++) {
var image:MovieClip = entity["image"+i];
var angle:Number = 90+360/total*i;
image._x = center.x+rx*Math.cos((angle+step)*radian);
image._y = center.y+ry*Math.sin((angle+step)*radian);
image._alpha = image._y-115;
image._xscale = image._yscale=(image._y-70)*.5;
image.swapDepths(image._y);
}
step += num;
updateAfterEvent();
}