Jump to content
Search Community

Menu buttons color changer

Dzsurnik test
Moderator Tag

Recommended Posts

Please help me

 

The task:

I want to make a menu, when I move the mouse over the button, change the button color, say blue, but if I move the mouse down from the button it will come back the original color and if I click the button itt will be yellow. And this yellow color will be active until another button is not clicked. And when clicked the second button it removes the first button yellow color. I hope it can understand what I want

 

Here is a little picture explanation:

Untitled-1.png

 

Here is my code:

stop();
import com.greensock.*;
import com.greensock.easing.*;
var switcher:Boolean=false;
var array_button:Array=["mc_button1","mc_button2"];
var selected_button=null;
var array_container=null;
trace(array_button);
trace(array_container);


//BUTTON 1
mc_button1.addEventListener(MouseEvent.MOUSE_DOWN , mc_button1_mouse_down);
function mc_button1_mouse_down(evt:MouseEvent):void {
if (switcher==true&&selected_button!=0) {
	array_container.name = array_button[selected_button];
	trace("array container: ",array_container);
	TweenMax.to(array_container, 1, {colorMatrixFilter:{colorize:0x000000, amount:1}});
	trace("a 2.button fekete lett");
} else {
	TweenMax.to(mc_button1, 1, {colorMatrixFilter:{colorize:0xff0000, amount:1}});
	switcher=true;
	trace("Mouse down rakkatintottam");
	selected_button=0;
	trace("Kivalasztott button szama: ",selected_button, "igy a tomb: ", array_button[selected_button]);
}
}
mc_button1.addEventListener(MouseEvent.MOUSE_OVER , mc_button1_mouse_up);
function mc_button1_mouse_up(evt:MouseEvent):void {
if (switcher==true) {
	trace("Mar ra lett kattintva a", array_button[selected_button],"gombra");
	//TweenMax.to(mc_button1, 1, {colorMatrixFilter:{colorize:0xFF65FF, amount:1}});
} else {
	TweenMax.to(mc_button1, 1, {colorMatrixFilter:{colorize:0xFF65FF, amount:1}});
	trace("Mouse over");
}
}
mc_button1.addEventListener(MouseEvent.MOUSE_OUT , mc_button1_mouse_out);
function mc_button1_mouse_out(evt:MouseEvent):void {
if (switcher==true) {
	//TweenMax.to(mc_button1, 1, {colorMatrixFilter:{colorize:0x00FF00, amount:1}});
	trace("Mar ra lett kattintva a", array_button[selected_button],"gombra");
} else {
	TweenMax.to(mc_button1, 1, {colorMatrixFilter:{colorize:0x00FF00, amount:1}});
	trace("Mouse out");

}
}

//BUTTON 2
mc_button2.addEventListener(MouseEvent.MOUSE_DOWN , mc_button2_mouse_down);
function mc_button2_mouse_down(evt:MouseEvent):void {
TweenMax.to(mc_button2, 1, {colorMatrixFilter:{colorize:0xff0000, amount:1}});
switcher=true;
trace("Mouse down rakkatintottam");
selected_button=1;
trace("Kivalasztott button szama: ",selected_button, "igy a tomb: ", array_button[selected_button]);
}
mc_button2.addEventListener(MouseEvent.MOUSE_OVER , mc_button2_mouse_up);
function mc_button2_mouse_up(evt:MouseEvent):void {
if (switcher==true) {
	//TweenMax.to(mc_button2, 1, {colorMatrixFilter:{colorize:0xFF65FF, amount:1}});
	trace("Mar ra lett kattintva a", array_button[selected_button],"gombra");
} else {
	TweenMax.to(mc_button2, 1, {colorMatrixFilter:{colorize:0xFF65FF, amount:1}});
	trace("Mouse over");
}
}
mc_button2.addEventListener(MouseEvent.MOUSE_OUT , mc_button2_mouse_out);
function mc_button2_mouse_out(evt:MouseEvent):void {
if (switcher==true) {
	//TweenMax.to(mc_button2, 1, {colorMatrixFilter:{colorize:0x00FF00, amount:1}});
	trace("Mar ra lett kattintva a", array_button[selected_button],"gombra");
} else {
	TweenMax.to(mc_button2, 1, {colorMatrixFilter:{colorize:0x00FF00, amount:1}});
	trace("Mouse out");
}
}

 

and I attached the fla

 

Please any Help would be great :)

thanks

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