I made a custom cursor -as a hammer and want to run an animation when I click the button. When the user clicks any buttons, hammer will hit(hammer) the button. I used 2 key frames in Cursor() class to make hammer animation and use several ways to implement it in my program -like gotoAndStop(), play() etc. But nothing works…
So, if you show me a way to solve this problem, I’ll be very appreciated.
Here is my code:
var menuCursor:MovieClip = new Cursor();
Mouse.hide();
menuCursor.mouseEnabled = false;
addEventListener(Event.ENTER_FRAME, cursorMenuMove);
menuCursor.gotoAndStop(1);
function cursorMenuMove(event:Event )
{
menuCursor.x = mouseX;
menuCursor.y = mouseY;
}
.
.
.
howToImageOn.addEventListener( MouseEvent.CLICK, run1HowTo );
.
.
.
function run1HowTo( event:MouseEvent )
{
menuCursor.gotoAndStop(2);
// or menuCursor.play();
whackSound.play(0,1);
menuMusicChannel.stop();
howToImageOn.removeEventListener( MouseEvent.MOUSE_OUT, howTo1Out );
playImageOff.removeEventListener( MouseEvent.MOUSE_OVER, play1Over );
creditsImageOff.removeEventListener( MouseEvent.MOUSE_OVER, credits1Over );
removeChild( playImageOff );
removeChild(howToImageOn);
removeChild( creditsImageOff);
removeChild( menuCursor );
gotoAndStop( "HowToPlay" );
}
I solved the problem using this code: