在这篇教程里,我们将学会如何利用Flash AS3代码绘制旋转的3D立体菜单动画效果,教木马将会根据鼠标决定旋转速度。教程绘制效果非常酷,转发过来,感兴趣的朋友快点来学习吧。
演示:
绘制步骤:
1、新建Flash文件,设置宽、高属性为 550 × 400 。
2、用圆角矩形工具,画一个 158 × 35的长方形。笔触为8白色,填充色#0 F7E 88。图1:
3、将长方形转换成名为 Menu Item 的影片剪辑。设定注册点为中心。图2:
4、双击舞台上的影片剪辑,进入编辑状态。创建动态文本,在它里面输入需要的本文。图3
5、在属性面板中输入实例名字 menuItemText 。
6、按下字符嵌入按钮,插入下列字型。图4:
7、切换回主场景1,删除舞台上的影片剪辑,实例将由代码生成。
8、打开库元件面板,右键单击影片剪辑,(CS3选链接、CS4选属性)给元件添加一个绑定类。类名 MenuItem 。图5:
9、选中第1帧,打开动作面板输入代码:
复制代码//The total number of menu items
const NUMBER_OF_ITEMS:uint = 20;
//This array will contain all the menu items
var menuItems:Array = new Array();
//Set the focal length
var focalLength:Number = 350;
//Set the vanishing point
var vanishingPointX:Number = stage.stageWidth / 2;
var vanishingPointY:Number = stage.stageHeight / 2;
//We calculate the angleSpeed in the ENTER_FRAME listener
var angleSpeed:Number = 0;
//Radius of the circle
var radius:Number = 128;
//Calculate the angle difference between the menu items (in radians)
var angleDifference:Number = Math.PI * (360 / NUMBER_OF_ITEMS) / 180;
//This loop creates and positions the carousel items
for (var i:uint = 0; i < NUMBER_OF_ITEMS; i++) {
//Create a new menu item
var menuItem:MenuItem = new MenuItem();
//Calculate the starting angle for the menu item
var startingAngle:Number = angleDifference * i;
//Set a currentAngle attribute for the menu item
menuItem.currentAngle = startingAngle;
//Position the menu item
menuItem.xpos3D = - radius * Math.cos(menuItem.currentAngle) * 0.5;










