Jump to content
Search Community

Do I need to write an if/else statement for button color

scottbrasher test
Moderator Tag

Recommended Posts

Do I need to write an if/else statement for my button color to change on/off when it is active?

 

Right now I have it set to tween from gray to red, my issue is getting it to go back to gray when another navigation button is clicked. I can do functions for each button, but there has to be a better way to set this up, I was thinking a conditional statement, but I am not very advanced with ActionScript, but I insist on doing things the right way....

 

Here is a bit of my code, and comments are greatly appreciated!

 

 

The gray color it needs to tween back to is #6D6E71 (or 0x6D6E71)


import com.greensock.*;
import com.greensock.easing.*;

this.why_mc.nav_titles_txt.text = "WHY IDS";
this.who_mc.nav_titles_txt.text = "WHO WE ARE";
this.loc_mc.nav_titles_txt.text = "LOCATIONS";
this.our_mc.nav_titles_txt.text = "OUR PARTNERS";
this.hom_mc.nav_titles_txt.text = "HOME";

TweenPlugin.activate([TintPlugin]);

why_mc.onRelease = function() {
gotoAndPlay("whySection");
TweenLite.to(whyText_mc, 1, {_x:315.95, _y:60.95, ease:Circ.easeOut});
TweenLite.to(why_mc.nav_titles_txt, 1, {tint:0xFF0000 })
};


who_mc.onRelease = function() {
gotoAndPlay("whoSection");
TweenLite.to(whoText_mc, 1, {_x:315.95, _y:60.95, ease:Circ.easeOut});
TweenLite.to(who_mc.nav_titles_txt, 1, {tint:0xFF0000 })
};

loc_mc.onRelease = function() {
gotoAndPlay("locSection");
TweenLite.to(locText_mc, 1, {_x:315.95, _y:60.95, ease:Circ.easeOut});
TweenLite.to(loc_mc.nav_titles_txt, 1, {tint:0xFF0000 })
};

our_mc.onRelease = function() {
gotoAndPlay("ourSection");
TweenLite.to(log_mc, 1, {_x:350.40, _y:69.95, ease:Circ.easeOut});
TweenLite.to(our_mc.nav_titles_txt, 1, {tint:0xFF0000 })
};

hom_mc.onRelease = function() {
gotoAndStop("homeSection");
TweenLite.to(hom_mc.nav_titles_txt, 1, {tint:0xFF0000 })
fadeIn();
fadeInB();
};

Link to comment
Share on other sites

quite a bit.

 

here is a simplified as2 approach. file attached

 

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;

TweenPlugin.activate([TintPlugin]);

//create reference to the currently active button
var currentButton:MovieClip;

b1.onRelease = function(){
activate(this);
}

b2.onRelease = function(){
activate(this);
}	

b3.onRelease = function(){
activate(this);
}	


function activate(btn){

//de-activate currentButton if there is one
if(currentButton){
	TweenLite.to(currentButton, .5, {tint:0x0000})
	}

//activate the button that was clicked	
TweenLite.to(btn, .5, {tint:0xff6600});
currentButton = btn;

}	

Link to comment
Share on other sites

var currentButton:MovieClip;
function activate(btn){

  //de-activate currentButton if there is one
  if(currentButton){
     TweenLite.to(currentButton.nav_titles_txt, .5, {tint:0x6D6E71})
     }

  //activate the button that was clicked   
  TweenLite.to(btn.nav_titles_txt, .5, {tint:0xFF0000});
  currentButton = btn;

  }    

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...