0
votes

I've got a screen which involves a movie-clip where the object has a outline to symbolize that it can be clicked. Upon clicking the object, I'm requesting it to do numerous functions, disable itself and then go to another frame which removes the outline symbolizing it cannot be clicked anymore. But once you disable an object it goes to the original frame.

The object itself consists of these 3 frames.

Frame 1: Original State (Glow) Frame 2: Hover over giving stats Frame 3: No glow

To summerise i'd like to click the object and for it to go to the no glow frame and disable the movieclip.

The movieclip enabled = 1 is for when the user returns to the this frame, so the scene is aware of the button press.

Movieclip.addEventListener(MouseEvent.CLICK, Fun_Movieclip);
Movieclip.addEventListener(MouseEvent.MOUSE_OVER, Fun_MovieclipMouseOver);
Movieclip.addEventListener(MouseEvent.MOUSE_OUT, Fun_MovieclipMouseOut);
function Movieclip(event:MouseEvent):void
{
    MovieclipEnabled = 1;
Movieclip.gotoAndStop(1);
Movieclip.mouseEnabled = false;
}

function Fun_MovieclipMouseOver(event:MouseEvent):void
{
Movieclip.gotoAndStop(2);
}

function Fun_MovieclipMouseOut(event:MouseEvent):void
{
Movieclip.gotoAndStop(3);
}

For some reason when ever the movieclip is disabled, it always reverts back to the glow state. Does anyone have a solution for this? Cheers

Edit: Inside the movieclip, the first frame has Stop();. Don't know if this would interfere with it.

1
Did you read about SimpleButton? - Nicolas Siver
how about just removing the eventlistener and adding it when you need it again? - user2655904
1 Is (MouseEvent.CLICK, Fun_Movieclip) and function Movieclip(event:MouseEvent) supposed to work together? They wont if the function names dont match. 2 Make sure MovieclipEnabled has been declared as a variable (type: int or number). 3 Read up on if/else statemnts. good link. When you get it then try if ( MovieclipEnabled == 1) { //do required} else { //do alternative to if == 1 } - VC.One

1 Answers

0
votes
mc.addEventListener(MouseEvent.CLICK, clickHandler);
mc.addEventListener(MouseEvent.MOUSE_OVER, mouseoverHandler);
mc.addEventListener(MouseEvent.MOUSE_OUT, mouseoutHandler);
function clickHandler(event:MouseEvent):void
{
    mc.gotoAndStop(3);
    mc.removeEventListener(MouseEvent.CLICK, clickHandler);
    mc.removeEventListener(MouseEvent.MOUSE_OVER, mouseoverHandler);
    mc.removeEventListener(MouseEvent.MOUSE_OUT, mouseoutHandler);
}

function mouseoverHandler(event:MouseEvent):void
{
    mc.gotoAndStop(2);
}

function mouseoutHandler(event:MouseEvent):void
{
    mc.gotoAndStop(1);
}

Not entirely sure what you meant by:

The movieclip enabled = 1 is for when the user returns to the this frame, so the scene is aware of the button press.

My suggestion for getting the scene to recognize the button click is to have the scene also listen to the mouse click handler