Skip to main content
Inspiring
June 12, 2024
Question

simple buttons to control timeLine confusion

  • June 12, 2024
  • 4 replies
  • 1352 views

Hi guys back again already. So I have a button, fire16, controlling the frames of another movieClip on the timeLine, instance named score, which is simply 0-1-2-3-4-5 dots over 6 frames to show the score.

 

this.fire16.addEventListener("click", fireSweet.bind(this));
function fireSweet()
{
var TP = this.score.timeline.position++;
this.score.gotoAndPlay(TP);
}

Well this code works well for first click, goes from frame 0 to frame 1 every time but after that it almost seems to go off random each new click. Any help would be much appreciated!

    This topic has been closed for replies.

    4 replies

    nurba
    Participating Frequently
    June 13, 2024

    Hi,

    I think it will be simpler to understand your full code.

    fix looks simple,

    but  structure of your code and movieclips are not clear

    Can you share your file?

    JoãoCésar17023019
    Community Expert
    Community Expert
    June 12, 2024

    Hi.

     

    It's because when you run var TP = this.score.timeline.position++, the timeline's position is offset by 1 immediately but TP doesn't get the timeline's position + 1 in return because you're using ++ in the end.

     

    Also, you should use gotoAndStop.

     

    Anyway, it's just easier to run this.score.gotoAndStop(this.score.currentFrame + 1), as suggested by k.

     

    Regards,

    JC

    Inspiring
    June 13, 2024

    As i said in my comments earlier I tried that, in fact that's what I started with, it doesn't work. See my actual code below -

    AND --> the only reason i have gotoAndPlay is because i have a stop command on all 6 frames of the score clip

     

    this.fire16.addEventListener("click", fireSweet.bind(this));
    function fireSweet()
    {
    this.pepe.visible=false;
    this.shit16.visible=true;
    this.shit16.play();

    this.score.gotoAndPlay(this.score.currentFrame+1)
    }

    JoãoCésar17023019
    Community Expert
    Community Expert
    June 13, 2024

    The approach I explained does work if the code and coditions are the ones you provided in the beginning.

    https://drive.google.com/file/d/1UOLK0_bmzUhl1o9U0Xbcs60pS-HVe9tZ/view?usp=sharing

    If there's something else that needs to be addressed, please provide more details or a sample file.

    kglad
    Community Expert
    Community Expert
    June 12, 2024

    by timeline.position do you mean currentFrame?

    Inspiring
    June 12, 2024

    yes, i found it somewhere. I tried current frame it does the same thing.

    kglad
    Community Expert
    Community Expert
    June 12, 2024

    it's nonsense.

     

    use

     

    this.score.gotoAndPlay(this.score.currentFrame+1)

    kglad
    Community Expert
    Community Expert
    June 12, 2024

    what's this.score.timeline.position??