Skip to main content
Known Participant
December 1, 2020
Answered

Question_mouse cursor_click to hide_movieclip will not play after button clicked

  • December 1, 2020
  • 2 replies
  • 365 views

See Code Below - I have a simple mouse cursor exercise as part of a bigger project. Before I go forward, I want to know what code I must add / remove to make both movie clips "splash1_mc" and splash3_mc" play, once each button has been clicked. I have only created two buttons for now and having issues with the second button / movie clip action working. The first button works and the movie clip plays, the second button works but the second movie clip will not play at all. I have built it many different ways - different MC's, the same MC, different instance names, this.stop(); at first frame, separate frames on the main timeline - nothing works. This scene will eventually have at least 20 buttons to click using a time/score counter. As mentioned, this is part of a bigger project so want to get this correct before I move forward. Let me know what I can do so each 20 frame movie clip plays after each button clicked. Thanks! 

 
Main Timeline
stop();
stage.addChild(ball1_mc);
ball1_mc.mouseEnabled = false;
ball1_mc.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_5);
function fl_CustomMouseCursor_5(event:Event)
{
            ball1_mc.x = stage.mouseX;
            ball1_mc.y = stage.mouseY;
}
Mouse.show();  // this is superfluous unless there's code elsewhere that hid the mouse
splash1_mc.visible = false;
splash3_mc.visible = false;
jelly1_mc.addEventListener(MouseEvent.CLICK, fl_ClickToHide_15);
function fl_ClickToHide_15(event:MouseEvent):void
{
jelly1_mc.visible = false;
splash1_mc.visible = true;
}
jelly2_mc.addEventListener(MouseEvent.CLICK, fl_ClickToHide_14);
function fl_ClickToHide_14(event:MouseEvent):void
{
jelly2_mc.visible = false;
splash3_mc.visible = true;
}

 

Movie Clip to play twice, then stop (want mc's like this play twice after each button clicked - want at least 20 on main timeline.)

 

if (!this.looped) this.looped = 1;
if (this.looped++ > 2) this.stop();

 

    This topic has been closed for replies.
    Correct answer kglad

    place a stop() on their first frame, add play() in your two hide listeners:

     

    jelly1_mc.addEventListener(MouseEvent.CLICK, fl_ClickToHide_15);
    function fl_ClickToHide_15(event:MouseEvent):void
    {
    jelly1_mc.visible = false;
    splash1_mc.visible = true;
    splash1_mc.play();
    }
    jelly2_mc.addEventListener(MouseEvent.CLICK, fl_ClickToHide_14);
    function fl_ClickToHide_14(event:MouseEvent):void
    {
    jelly2_mc.visible = false;
    splash3_mc.visible = true;
    splash3_mc.play();
    }

    2 replies

    cmdhAuthor
    Known Participant
    December 1, 2020

    It works - yay! Thanks so much kglad. 😊

    kglad
    Community Expert
    Community Expert
    December 1, 2020

    you're welcome.

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    December 1, 2020

    place a stop() on their first frame, add play() in your two hide listeners:

     

    jelly1_mc.addEventListener(MouseEvent.CLICK, fl_ClickToHide_15);
    function fl_ClickToHide_15(event:MouseEvent):void
    {
    jelly1_mc.visible = false;
    splash1_mc.visible = true;
    splash1_mc.play();
    }
    jelly2_mc.addEventListener(MouseEvent.CLICK, fl_ClickToHide_14);
    function fl_ClickToHide_14(event:MouseEvent):void
    {
    jelly2_mc.visible = false;
    splash3_mc.visible = true;
    splash3_mc.play();
    }