5 Replies Latest reply on Apr 1, 2010 7:32 AM by Ned Murphy

    Help with rotating circular menu

    alxanimation2010

      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;
                               } 
                               }
      }
      } 
      

        • 1. Re: Help with rotating circular menu
          Ned Murphy Adobe Community Professional & MVP

          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.

          • 2. Re: Help with rotating circular menu
            alxanimation2010 Level 1

            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...

            • 3. Re: Help with rotating circular menu
              Ned Murphy Adobe Community Professional & MVP

              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.

              1 person found this helpful
              • 4. Re: Help with rotating circular menu
                alxanimation2010 Level 1

                Sorry I did't make myslef clear, but yes, the lightning is involved when any button is being rolled over.

                 

                I know how to make a lightning appear ON TOP of my buttons, but not next to it at an angle that changes constantly.

                 

                You can look up the fla http://idisk.mac.com/animationap//Public/mendat_ds_science_04.fla.zip

                 

                mandat.pngmandat2.png

                • 5. Re: Help with rotating circular menu
                  Ned Murphy Adobe Community Professional & MVP

                  I'll probably have to leave you to minds greater than mine for a solution to this.  To have things arranged with long rectangles and a flattened oval shaped path around the center as you show complicates matters in terms of how the _x/_y properties need to vary in order to not be hitting the inner or outer buttons.

                   

                  If it were mine to solve I would probably bend towards making the buttons circular shapes that follow a truly circular path around the center.  Then I would only have to manage the _rotation value of the lightning bolt which would have its registration at the center of the central button--essentially going around like the hand of a clock.

                  1 person found this helpful