Skip to main content
Participant
April 1, 2010
Question

Help with rotating circular menu

  • April 1, 2010
  • 1 reply
  • 690 views

Hi there. With help from a few tutorials, I've made a menu with 5 buttons that rotate around a central Clip. So far so good.

Except I need to add a lightning that will point toward the center whenever a button is activated. Much like picture below:

http://idisk.mac.com/animationap//Public/mandat.png

Everything I've tried so far has produced unexpected results

So I would really appreciate any suggestions as to how I might fix my code (AS2) and get the lightning to position itself where it must be. Thanks!

var rotX:Number = 290; var rotY:Number = 140; var Centre:Number = Stage.height/2; var vitesse:Number = 0.1; var sceneW:Number =Stage.width; var sceneH:Number = Stage.height; var nbI:Number=5; var angle:Number=1; var i:Number; var lightning:MovieClip = this.attachMovie("lightning", "lightning", 1000); lightning._alpha = 0; var videostopped:Boolean = false; for(i=0;i<nbI;i++) {    //_____________________    var button:MovieClip = this.attachMovie('Icone'+i,'Ic'+i,i);    //_____________________    button.onRelease= onRelease;    button.onRollOut = onRollOut;    button.onRollOver = onRollOver;    button._y = sceneH /2; } //_____________________test function onRollOver():Void {         //I want to add a "lightning" movieClip between the center and the button that is rolled over         lightning._alpha = 100;    videostopped = true; } function onRollOut():Void {         //then remove it.    lightning._alpha = 0;    videostopped = false; } onEnterFrame=function(){            if (!videostopped) {            //_____       if (angle > (2*Math.PI))       {            angle = 0;       }else{                           for(i=0; i<nbI; i++){                //_____________________angle on x axis                this['Ic'+i]._x=rotX*Math.cos(angle+2*Math.PI*i/nbI)+sceneW/2;                                //_____________________angle on y axis                this['Ic'+i]._y=rotY*Math.sin(angle+2*Math.PI*i/nbI)+sceneH/2;                                //_____________________Speed                     angle=angle+(sceneW/180)/sceneH*vitesse;                          }                          } } }

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
April 1, 2010

Based on your description, where the lightning should point to the center as you show, why is it a problem to position the button in that one spot?  It appears to be a fixed position.

Participant
April 1, 2010

Not really, because all five buttons rotate at all time. So if the first button is pressed when when it's 30° into it's rotation, the lightning has to appear in a totally different position (and angle) than if I hit the second button later in it's rotation...

Ned Murphy
Legend
April 1, 2010

But the lightning doesn't appear to involve the 6 buttons, just the one at the center, as you described and showed.  Are you now saying the lightning doesn't go to the center as you show but instead goes to which button is being used?  If so, what you should do is have each button carry its own lightning bolt and control which button displays the one it carries.  If it only appears on rollovers, then that should be as simple as managing any button rollover.