Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a button for my game which has a MovieClip in it. It consists of an image of a lock and an image of an item, representing the item being locked and unlocked. I make the button become slightly smaller when the mouse is over it to create the effect of a button slightly down.

For some reason, however, this makes the MovieClip in the button go to the next frame. I have no Actionscript code in the button or any frame except stop() on the first frame of the MovieClip, so I really don't understand why this would happen. It only goes to the next frame when I hover my mouse over the button and then quickly goes back to the first frame (since there's no stop() in the second frame).

After experimenting with stop() in both frames of the movie clip, it does indeed only happen when my mouse enters the button. Leaving the button doesn't do anything and the button left alone doesn't do anything. It just changes the frame when I hover my cursor over it. There's absolutely no script involved aside from stop() in the first frame of the movie clip in the button. What could be the cause of this problem?

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

I wonder why you put a MovieClip with two frames inside a Button? From my experience the Flash Button is really broken and scripts won't work inside the button. So if you have a "locked" (frame 1) and "unlocked" (frame 2) image in your MovieClip, you won't be able to access the "unlocked" image, because using a script to get to frame 2 won't work properly in the first place.

Better create two separate Button instances, or script the MovieClip so that it works as a button directly (eg. scale it on mouse-over/mouse-out and use buttonMode and useHandCursor properties to control mouse-pointer behavior).

share|improve this answer
add comment

I wouldn't use a Button object. "Button" is simply a shortcut for some common button functionality like mouseover and click states; you can set mouse event listeners on any MovieClip. You probably also want to set buttonMode=true so that the mouse cursor will turn into the hand to indicate the user can click:

movieClip.addEventListener(MouseEvent.CLICK, onClick);
movieClip.buttonMode = true;
share|improve this answer
add comment

Try putting gotoAndStop(1) in the second frame of the movie clip

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.