3 Replies Latest reply on Jul 14, 2009 5:12 AM by _Natasha_

    Rotate Effect not working

    kris456 Level 1

      I wanted to Rotate a button when mouse pointer is hovered over it. But even if I set OrginX & originY to button.width/2 & button.height/2 respectively, it is rotating with top left corner of the button as rotating origin centre.

       

      I will attach the function used for rotating below.

       

       

      private function rotbut():void

                     {           
                   var rot:Rotate = new Rotate();
                   rot.target = but2;
                   rot.originX = (but2.width)/2;  //need it to rotate around it's center
                   rot.originY = (but2.height)/2;  //    -- " --                         
                   rot.angleTo = 360;            
                   rot.duration = 1000;
                   rot.play();            
                }

       

      The button is rotating, but its not rotating around its centre. rather its rotating with top left corner of the button as axis centre. Wat is wrong with ma code?

       

      Please Help me

        • 1. Re: Rotate Effect not working
          _Natasha_ Level 4

          Hi,

          Rotating works well and your function is ok.

           

          I think that the problem is in the positioning of Button. I think that data bindings for x and y position of but2 is working.

          For example, if you set that x position should be on the center, it will always be in the center.

           

          Show the code for your Button if you need more help.

          • 2. Re: Rotate Effect not working
            kris456 Level 1

            This is the code for the button

             

             

            <mx:Button id="but2" enabled="true" alpha="1.0" cornerRadius="20" fillAlphas="[0.0, 0.0, 0.0, 0.0]" borderColor="#030304" themeColor="#000000" horizontalCenter="0" verticalCenter="72" width="64" height="64" rightClick="rotbut()">
            <mx:icon>@Embed(source='/Icons/player_play-256 64x64.png')</mx:icon>

             

             

            N.B:- rotbut() is the function for rotating

            • 3. Re: Rotate Effect not working
              _Natasha_ Level 4

              If you remove horizontalCenter and verticalCenter all will work fine.

               

              But I cann't understand why rotating on center doesn't work to it...