AS3.0旋转菜单,中怎么知道每个实例的名字。并添加事件

这些是代码package{importflash.display.MovieClip;publicdynamicclassItemextendsMovieClip{pub... 这些是代码
package {
import flash.display.MovieClip;
public dynamic class Item extends MovieClip {
public function Item() {
}
}
}
保存在fla文件的同一目录下。
8、返回到场景1,在图层1的第一帧输入代码:
[code]//Save the center coordinates of the stage
var centerX:Number = stage.stageWidth / 2;
var centerY:Number = stage.stageHeight / 2;
//The number of items we will have (feel free to change!)
var NUMBER_OF_ITEMS:uint = 15;
//Radius of the menu circle (horizontal and vertical)
var radiusX:Number = 200;
var radiusY:Number = 100;
//Angle difference between the items (in radians)
var angleDifference:Number = Math.PI * (360 / NUMBER_OF_ITEMS) / 180;
//How fast a single circle moves (we calculate the speed
//according to the mouse position later on...)
var angleSpeed:Number = 0;
//Scaling speed of a single circle
var scaleSpeed:Number = 0.0002;
//This vector holds all the items
//(this could also be an array...)
var itemVector:Vector.<Item> = new Vector.<Item> ;
//This loop creates the items and positions them
//on the stage
for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
//Create a new menu item
var item:Item = new Item();
//Get the angle for the item (we space the items evenly)
var startingAngle:Number = angleDifference*i;
//Set the x and y coordinates
item.x = centerX + radiusX * Math.cos(startingAngle);
item.y = centerY + radiusY * Math.sin(startingAngle);
//Save the starting angle of the item.
//(We have declared the Item class to be dymamic. Therefore,
//we can create new properties dynamically.)
item.angle = startingAngle;
//Add an item number to the item's text field
item.itemText.text = i.toString();
//Allow no mouse children
item.mouseChildren = false;
//Add the item to the vector
itemVector.push(item);
//Add the item to the stage
addChild(item);
}
//We use ENTER_FRAME to animate the items
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
//This function is called in each frame
function enterFrameHandler(e:Event):void {
//Calculate the angle speed according to mouse position
angleSpeed = (mouseX - centerX) / 5000;
//Loop through the vector
for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
//Save the item to a local variable
var item:Item = itemVector[i];
//Update the angle
item.angle += angleSp
//Set the new coordinates
item.x = centerX + radiusX * Math.cos(item.angle);
item.y = centerY + radiusY * Math.sin(item.angle);
//Calculate the vertical distance from centerY to the item
var dy:Number = centerY - item.y;
//Scale the item according to vertical distance
item.scaleY = (dy / radiusY);
//If we are above centerY, double the y scale
if (item.y<centerY) {
item.scaleY *= 2;
}
//Set the x scale to be the same as y scale
item.scaleX = item.scaleY;
//Adjust the alpha according to y scale
item.alpha = item.scaleY + 1.1;
}
}

搞笑呢,我自己都解决了还没人答
展开
 我来答
dcpromowang
2012-11-30 · TA获得超过907个赞
知道小有建树答主
回答量:734
采纳率:100%
帮助的人:466万
展开全部
那岂不更好!?自己做出来印象更深刻。下次遇到就不用求人了
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式