Flash CS4 - 3D Rotating Menu






Download RotatingMenu.zip (8 KB)


ActionScript Code:

// Developed by Anil kumar N D
// anilkumarnd@gmail.com
// http://flash-workshop.blogspot.com/
// ActionScript 3.0

package {
import flash.display.MovieClip;
import flash.events.*;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BlurFilter;
import flash.filters.DropShadowFilter;

public class RotatingMenu extends MovieClip {

var RectNo:Number=10;
var i:Number;
var rectangle:MovieClip;
var radius:Number;
var speed:Number=0;
var xcenter:Number;
var ycenter:Number;
var degree:Number;
var radian:Number=0;
var MovieClipArray:Array=new Array ;

var rectContainer:MovieClip=new MovieClip ;

var newFormat:TextFormat = new TextFormat();

public function RotatingMenu():void {

stage.frameRate=30;

CreateRectz();

}

function CreateRectz():void {

addChild(rectContainer);

for (i=0; i<RectNo; i++) {

rectangle=CreateRect(0x000000,70,45);

var txt_menu:TextField = new TextField();

txt_menu.text="Menu "+i;

txt_menu.selectable=false;

txt_menu.mouseEnabled=false;

txt_menu.width=60;

txt_menu.height=20;

txt_menu.x=-30;

txt_menu.y=-10;

newFormat.size=15;

newFormat.bold=true;

newFormat.color=0xFFFFFF;

newFormat.align=TextFormatAlign.LEFT;

txt_menu.setTextFormat(newFormat);

rectangle.addChild(txt_menu);

rectangle.radius=125;

rectangle.speed=speed;

rectangle.degree=i*360/RectNo;

rectangle.radian=rectangle.degree/180*Math.PI;

rectangle.x=+ Math.cos(rectangle.radian)*rectangle.radius;

rectangle.y=- Math.sin(rectangle.radian)*rectangle.radius/5;

rectangle.mouseChildren=false;

MovieClipArray[i]=rectangle;
rectContainer.buttonMode=true;

rectContainer.addChild(rectangle);

rectangle.addEventListener(Event.ENTER_FRAME,RotateFunction);
rectangle.addEventListener(MouseEvent.MOUSE_OVER,OverFunction);
rectangle.addEventListener(MouseEvent.MOUSE_OUT,OutFunction);

}

rectContainer.x=stage.stageWidth/2;

rectContainer.y=stage.stageHeight/2;

stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveFunction);

}

function mouseMoveFunction(e:Event):void {

speed = (mouseX-(stage.stageWidth/2))/100;

}

function RotateFunction(e:Event):void {

MovieClip(e.target).scaleX =((((Number(MovieClip(e.target).y)+50)*30)/100)+70)/100;

MovieClip(e.target).scaleY = ((((Number(MovieClip(e.target).y)+50)*30)/100)+70)/100;


var NumBlur:Number = -Number(MovieClip(e.target).y-30);

NumBlur = NumBlur/5;

MovieClip(e.target).filters=[(new BlurFilter(NumBlur,NumBlur,BitmapFilterQuality.HIGH))];

if (MovieClip(e.target).x>14&&MovieClip(e.target).y<250) {

rectContainer.setChildIndex(MovieClip(e.target),0);
}

if (MovieClip(e.target).y>14&&MovieClip(e.target).x<250) {

rectContainer.setChildIndex(MovieClip(e.target),MovieClipArray.length - 1);
}

 

e.target.degree+=speed;

e.target.radian=e.target.degree/180*Math.PI;

e.target.x=+ Math.cos(e.target.radian)*e.target.radius;

e.target.y=- Math.sin(e.target.radian)*e.target.radius/5;

 

}

function OverFunction(e:MouseEvent):void {

for (i=0; i<RectNo; i++) {

MovieClipArray[i].removeEventListener(Event.ENTER_FRAME,RotateFunction);

}

}

function OutFunction(e:MouseEvent):void {

for (i=0; i<RectNo; i++) {

MovieClipArray[i].addEventListener(Event.ENTER_FRAME,RotateFunction);

}

}

private function CreateRect(color:Number,Width:Number,Height:Number):MovieClip {

var Rect:MovieClip=new MovieClip ;

Rect.graphics.beginFill(color,.7);

Rect.graphics.drawRect(0-Width/2,0-Height/2,Width,Height);

Rect.graphics.endFill();

return Rect;
}
}
}



Comments

Dinesh holla said…
hi.. anil nice work..
this is cool for looks, but there is no way to link the menu items or give them graphics, ect..
Anonymous said…
kept trying to download the zip file, nothing comes up. also tried cutting and pasting code straight into as, and keep getting a "package cannot be neted" error.
Rohit said…
hiii anil
really it's nice
zum Feierabend said…
Hi, nice works, we will use them aprtly and make of course a donation.

http://www.clickandsell.info/
Unknown said…
you got skills brother.
Anonymous said…
That's really creative Anil. I must say you are master mind :) Good on you.
flash website developer
INTELED said…
Very usefull, Thanks a lot! Inteled

Popular posts from this blog

Simple Flash Analog Clock - AS3

AS3 - Access objects from external SWF files