Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 92756

Re: How to make a rotating Item Select for a GUI design

$
0
0

buttons have a number of limitations that movieclips do not have.  the only benefit of buttons is that they require no coding for up,over,down states while movieclips do.

 

anyway, if your up arrow is up_arrow, down arrow is down_arrow and your guns are gun_0,gun_1 etc:

 

// assign x0,y0 etc to match the 5 positions of your weapons. 

var index:int = 0;

var positionA:Array = [ [x0,y0],[x1,y1],...,[x4,y4] ];

up_arrow.addEventListener(MouseEvent.CLICK,rotateF);

down_arrow.addEventListener(MouseEvent.CLICK,rotateF);

 

function rotateF(e:MouseEvent):void{

for(var i:int=0;i<positionA.length;i++){

for(var j:int=0;j<positionA.length;j++){

if(this["gun_"+i].y==positionA[j][1];){

if(e.currentTarget.name=="up_arrow"){

var nextJ:int=(j+1)%positionA.length;

} else {

nextJ = (j+positionA.length-1)%positionA.length;

}

this["gun_"+i].x=positionA[nextJ][0];

this["gun_"+i].y=positionA[nextJ][1];

this["gun_"i].scaleX=this["gun_"+i].scaleY=1;

if(j==2){

this["gun_"i].scaleX=this["gun_"+i].scaleY=2;

}

break;

}

}

}

}


Viewing all articles
Browse latest Browse all 92756

Trending Articles