Skip to main content
Participant
January 30, 2021
Answered

Can't play/stop 1 ball

  • January 30, 2021
  • 1 reply
  • 509 views

Hello everyone.

 

Please help!

Has 2 jumping balls and 2 buttons (one stop and one play).

 

When use both ball - all work (push stop button - both balls stop, play button - both balls moving):

import flash.events.MouseEvent;
function ClickStop(Event:MouseEvent){
  stop();
}
stop_button.addEventListener(MouseEvent.MOUSE_UP, ClickStop);
function ClickPlay(Event:MouseEvent){
  play();
}
play_button.addEventListener(MouseEvent.MOUSE_UP, ClickPlay);

 

But when try to stop/play only one ball by same buttons- it does't work:

import flash.events.MouseEvent;
function ClickStop(Event:MouseEvent){
  RB.stop();
}
stop_button.addEventListener(MouseEvent.MOUSE_UP, ClickStop);
function ClickPlay(Event:MouseEvent){
  RB.play();
}
play_button.addEventListener(MouseEvent.MOUSE_UP, ClickPlay);

RB - is the instance name.

 

Also try a layer name.

But nothing..

Please help!

    This topic has been closed for replies.
    Correct answer kglad

    shift click (the first frame and last frame in RB' layer) to select all the frames in RB's animation >right click >click cut frames.  then double click the library symbol for RB to go to its timeline >right click the first frame and click paste.

     

    same for the other ball.

     

    p.s.  i usually charge for downloading and fixing your fla.  if you still want me to do that send me a private message.

    1 reply

    kglad
    Community Expert
    Community Expert
    January 30, 2021

    if the top code snippet ever worked, you would need to change your setup for the bottom code snippet to work.

     

    ie, the top code works when there's animation on the timeline that contains that code and if that stops both balls it means both are animated on that timeline.  the bottom code would work if RB were animated on its own timeline, not the timeline that contains that code.

     

    solution: copy the animation from the parent timeline and paste into each ball's timeline.

    Daria5CEEAuthor
    Participant
    January 30, 2021
    you are right, both balls are on the same timeline now.
    but cound you tell me how I can "copy the animation from the parent timeline and paste into each ball's timeline"?
    I tried to open the scene panel and create three scenes each with each timeline, but they are played sequentially (buttons first, then buttons disaapear and jumping green ball appear, then a jumping red ball), but I need everything to be together on the display.
    and code still not working.
    thank you
    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    January 30, 2021

    shift click (the first frame and last frame in RB' layer) to select all the frames in RB's animation >right click >click cut frames.  then double click the library symbol for RB to go to its timeline >right click the first frame and click paste.

     

    same for the other ball.

     

    p.s.  i usually charge for downloading and fixing your fla.  if you still want me to do that send me a private message.