6 Replies Latest reply on Feb 14, 2011 8:59 PM by BNavigator-K

    custom three part animated cursor

    BNavigator-K

      Ok, I'm trying to see if I can set up a custom style cursor in a flash file.  The idea is to have the static image of a chicken bone (Don't ask) for the primary cursor, swaping to a movie clip of the bone with a fancy glowing effect when it mouses over specific objects, and finally movieclip of a short flash when the mouse clicks in the area.  Being less then expert with actionscript 3, I tried using code snipets, first to try swaping between the three clips (Which with a little tinkering worked allright with two, but adding the third messed everything up.)  However looking at the big mass of code and multiple symbols, I decided to instead make a symbol, and put each of the three cursors symbols into a different frame, then set the event handlers to simply move between frames in the symbol. On creating the test swf, I found that the glowing effect was looping prematurely creating a stuttering effect, and the click effect doesn't always trigger, and sometimes once triggered, it won't change back.

      Here's the code I was using, any thoughts on what I might be doing wrong?

       

       

      stage.addChild(BoneCursor);

      BoneCursor.mouseEnabled = false;

      BoneCursor.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_4);

       

      function fl_CustomMouseCursor_4(event:Event)

      {

           BoneCursor.x = stage.mouseX;

           BoneCursor.y = stage.mouseY;

      }

      Mouse.hide();

       

       

      movieClip_1.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_2);

       

      function fl_MouseOverHandler_2(event:MouseEvent):void

      {

      BoneCursor.gotoAndStop(2);

      }

       

       

      movieClip_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

       

      function fl_MouseClickHandler(event:MouseEvent):void

      {

      BoneCursor.gotoAndStop(3);

      }

       

       

      movieClip_1.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_3);

       

      function fl_MouseOutHandler_3(event:MouseEvent):void

      {

      BoneCursor.gotoAndStop(1);

      }

        • 1. Re: custom three part animated cursor
          robdillon Most Valuable Participant

          Why not just integrate the parts of the cursor into a single movieClip?

          • 2. Re: custom three part animated cursor
            Ned Murphy Adobe Community Professional & MVP

            My thoughts are that something going on inside is causing the issue, not the code you show.  IF I use that code for a three-framed mc that just switches frames, it works fine.

            • 3. Re: custom three part animated cursor
              BNavigator-K Level 1

              Still working with the cursor question on and off, the problem seems to be that for some reason the goto command is being repeatedly exorcised in rapid succession.  I did try fixing it by adding a variable with a value of 1 or 2, and then surounding the gotoAndPlay command with an IF statement asking the value of the variable, then changing it after executing the gotoAndPlay.

               

              I also reworked a test cursor so that instead of three frames with three seperate movie clips forming the cursor movieclip Symbol, the cursor movieclip symbol had one frame(With a stop command) for the first cursor, then a tween for the animated portion.  Mainly made the change to try doing more of the animation inside flash instead of imported from aftereffects inc case that was where the trouble was coming from, but the end result still kept restarting the animation rather than letting it loop at full length.

              Any thoughts on where this problem could be arising from?

              • 4. Re: custom three part animated cursor
                moccamaximum Level 5

                put in an additional Line:

                BoneCursor.mouseChildren = false;

                 

                also change

                BoneCursor.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_4);

                 

                to

                 

                BoneCursor.addEventListener(MouseEvent.MOUSE_MOVE, fl_CustomMouseCursor_4);

                • 5. Re: custom three part animated cursor
                  BNavigator-K Level 1

                  Changing Event.ENTER_FRAME to MouseEvent.MOUSE_MOVE made the cursor dissapear altogether , but just adding BoneCursor.mouseChildren = false; to MouseOverHandler_2 function seems to have completely fixed all the problems.

                   

                  Thanks for the help.

                  • 6. Re: custom three part animated cursor
                    BNavigator-K Level 1

                    Modified the MOUSE_OVER function from:

                     

                    function fl_MouseOverHandler_2(event:MouseEvent):void

                    {

                         BoneCursor.gotoAndStop(2);

                    }

                    To

                    function fl_MouseOverHandler_2(event:MouseEvent):void

                    {

                         BoneCursor.gotoAndStop(2);

                         BoneCursor.mouseChildren = false;

                    }