Jump to content
Search Community

ClickedOn button state for labeling in TimeLineMax

ngrinchenko test
Moderator Tag

Recommended Posts

I have an animation separated into two labels in TimelineMax set up.

There are two buttons which lead to animation's part A and animation part B.

I set it up with addLabel/duration method.

Each button has its rollover state done as var with TweenMax which I play and reverse on roll over and out.

Is it possible to have a set up that once button A is clicked and leads a user to section A then the button A permanently have a rollOver state indicating that it should not be clicked as a user is in the section A already? And the same would go for button B?

Link to comment
Share on other sites

yes, but this concept isn't really related to TimelineMax. you could do something like:

 

buttonA.addEventListener(MouseEvent.CLICK, buttonAClick);
buttonB.addEventListener(MouseEvent.CLICK, buttonBClick);

function buttonAClick(e:MouseEvent):void{
 //disable button A
  buttonA.removeEventListener(MouseEvent.CLICK, buttontAClick);
  buttonA.alpha = .2;
  //goto timeline section
  //tl.gotoAndPlay("sectionA");
  //enable buttonB
  buttonB.addEventListener(MouseEvent.CLICK, buttonBClick);
 buttonB.alpha = 1;
}


function buttonBClick(e:MouseEvent):void{
 //disable button B
  buttonB.removeEventListener(MouseEvent.CLICK, buttontBClick);
  buttonB.alpha = .2;
  //goto timeline section
  //tl.gotoAndPlay("sectionB");
  //enable buttonA
  buttonA.addEventListener(MouseEvent.CLICK, buttonAClick);
  buttonA.alpha = 1;
}

 

if you read the code you will see that it does exactly like you described

 

clicking buttonA:

-makes buttonA not clickable by removing the eventlistener

-makes it look different by changing the alpha (do what you want)

-enables buttonB

 

 

there are more efficient ways that involve storing a reference to the disabled button and dynamically enabling it when another button is pressed, or looping through an array of buttons and toggling an enabled property on each button. There are many ways. Try googling "as3 disable button".

 

for now the code above will work fine with 2 buttons.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...