Copy link to clipboard
Copied
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!
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;
}
}
Copy link to clipboard
Copied
Hi.
AS3 or JavaScript?
And what is your code and where is it placed now?
Regards,
JC
Copy link to clipboard
Copied
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();
Copy link to clipboard
Copied
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!!!
Copy link to clipboard
Copied
are mc_animals and both buttons on the same timeline?
when are the buttons visible?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now