在库中有一个命名为Shouji类的movieclip。这个movieclip里在第一帧写着stop(); 并且从第一帧到第五帧,每一帧都有一张图片。
代码如下:
import flash.display.Sprite;
import flash.display.MovieClip;
var menu:Sprite = new Sprite();
menu.x = 275;
menu.y = 180;
this.addChild(menu);
var disx:Number = 200;
var disy:Number = 30;
var speed:Number = 0;
menu.addEventListener(Event.ENTER_FRAME,xuanzhuan);
jiashouji(5);
function jiashouji(e:Number):void
{
for(var i:int = 0;i<e;i++)
{
var mc:Shouji = new Shouji();
menu.addChild(mc);
}
}
//EnterFrame事件的函数
function xuanzhuan(e:Event):void
{
var sss:Array = new Array();
var b:int = menu.numChildren;
for(var z:int=0;z<b;z++)
{
var fen:Number = 360/b;
var mc = menu.getChildAt(z);
mc.gotoAndStop(z+1);
mc.x = (Math.cos(fen*(Math.PI/180)*(z+1)+speed))*disx;
mc.y = (Math.sin(fen*(Math.PI/180)*(z+1)+speed))*disy;
dx(mc,"scaleX",.2,.7);
dx(mc,"scaleY",.2,.7);
sss[z]=mc;
}
//speed+=(mouseX-275)/275*0.2;
speed+=0.07;
sd(sss);
}
//随着Y轴改变大小
function dx(mc:MovieClip,p:String,n1:Number,n2:Number):void
{
mc[p]=(mc.y+disy)/(2*disy)*(n2-n1)+n1
}
//随着Y轴改变深度
function sd(sss:Array):void
{
sss.sortOn("y",Array.NUMERIC);
var i:int = sss.length;
while(i--)
menu.setChildIndex(sss[i],i);
}
代码如下:
import flash.display.Sprite;
import flash.display.MovieClip;
var menu:Sprite = new Sprite();
menu.x = 275;
menu.y = 180;
this.addChild(menu);
var disx:Number = 200;
var disy:Number = 30;
var speed:Number = 0;
menu.addEventListener(Event.ENTER_FRAME,xuanzhuan);
jiashouji(5);
function jiashouji(e:Number):void
{
for(var i:int = 0;i<e;i++)
{
var mc:Shouji = new Shouji();
menu.addChild(mc);
}
}
//EnterFrame事件的函数
function xuanzhuan(e:Event):void
{
var sss:Array = new Array();
var b:int = menu.numChildren;
for(var z:int=0;z<b;z++)
{
var fen:Number = 360/b;
var mc = menu.getChildAt(z);
mc.gotoAndStop(z+1);
mc.x = (Math.cos(fen*(Math.PI/180)*(z+1)+speed))*disx;
mc.y = (Math.sin(fen*(Math.PI/180)*(z+1)+speed))*disy;
dx(mc,"scaleX",.2,.7);
dx(mc,"scaleY",.2,.7);
sss[z]=mc;
}
//speed+=(mouseX-275)/275*0.2;
speed+=0.07;
sd(sss);
}
//随着Y轴改变大小
function dx(mc:MovieClip,p:String,n1:Number,n2:Number):void
{
mc[p]=(mc.y+disy)/(2*disy)*(n2-n1)+n1
}
//随着Y轴改变深度
function sd(sss:Array):void
{
sss.sortOn("y",Array.NUMERIC);
var i:int = sss.length;
while(i--)
menu.setChildIndex(sss[i],i);
}