Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

invisible buttons controlled by nested movieclip

Community Beginner ,
Jun 27, 2019 Jun 27, 2019

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!

295
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 27, 2019 Jun 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;

}

}

Translate
Community Expert ,
Jun 27, 2019 Jun 27, 2019

Hi.

AS3 or JavaScript?

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

Regards,

JC

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 27, 2019 Jun 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();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 27, 2019 Jun 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!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2019 Jun 27, 2019

are mc_animals and both buttons on the same timeline?

when are the buttons visible?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 27, 2019 Jun 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2019 Jun 27, 2019
LATEST

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;

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines