Skip to main content
Participating Frequently
June 27, 2019
Answered

invisible buttons controlled by nested movieclip

  • June 27, 2019
  • 2 replies
  • 346 views

Hi,

I have buttons btn_next and btn_previous in my timeline for controlling a movieclip mc_animals. However, I wanna btn_previous.visible = false when mc_animals is in the first frame, and btn_next.visible = false when mc_animals is in the last frame (frame 15 in this case).

Have been trying to create a function but didn't succeed... and I am also in doubt if the function should be placed in any frame in my timeline, or inside the timeline of the mc_animals.

Any guidance?

Thanks!

This topic has been closed for replies.
Correct answer kglad

on that timeline that contains all 3 objects:

var animalsI;

clearInterval(animalsI);

animalsI=setInterval(animalsF.bind(this),1000/createjs.Ticker.framerate);

function animalsF(){

if(this.mc_animals.currentFrame==0){

this.btn_previous.visible=false;

} else {

this.btn_previous.visible=true;

}

if(this.mc_animals.currentFrame==this.mc_animals.totalFrames-1){

this.btn_next.visible=false;

} else {

this.btn_next.visible=true;

}

}

2 replies

kglad
Community Expert
June 27, 2019

are mc_animals and both buttons on the same timeline?

when are the buttons visible?

LeticiaMRAuthor
Participating Frequently
June 27, 2019

Yes, all 3 are actually in the same frame at the timeline... and actually no matter where I place the function and/or call it, the previous button is still showing.

The closest response I got was that the whole frame disappeared (like skipped the frame) where the previous buttons should been invisible.

kglad
kgladCorrect answer
Community Expert
June 27, 2019

on that timeline that contains all 3 objects:

var animalsI;

clearInterval(animalsI);

animalsI=setInterval(animalsF.bind(this),1000/createjs.Ticker.framerate);

function animalsF(){

if(this.mc_animals.currentFrame==0){

this.btn_previous.visible=false;

} else {

this.btn_previous.visible=true;

}

if(this.mc_animals.currentFrame==this.mc_animals.totalFrames-1){

this.btn_next.visible=false;

} else {

this.btn_next.visible=true;

}

}

JoãoCésar17023019
Community Expert
June 27, 2019

Hi.

AS3 or JavaScript?

And what is your code and where is it placed now?

Regards,

JC

LeticiaMRAuthor
Participating Frequently
June 27, 2019

Hi João!

I forgot to mention it ... sorry. It's HTML5 doc, so I guess it is JavaScript, right?

I tried creating the below function at first frame of my timeline...

this.prevBtnVisibility = function() {

var frameNumber = this.mc_animals.currentFrame;

if (frameNumber == 0){

this.btn_previous.visible = false;}

else {

this.btn_previous.visible = true; }

then calling the function from within the nested movieclip:

parent.prevBtnVisibility();

LeticiaMRAuthor
Participating Frequently
June 27, 2019

Hey guys!

I've realized my mistake!!

When calling the function within the nested movieclip, I have to use:

this.parent.prevBtnVisibility();

I was forgetting the this.

Thanks!!!