Jump to content
Search Community

"noTint" removing effect button problem

blackflow test
Moderator Tag

Recommended Posts

Hi, I have two buttons.If U click one button it tint's. The problem is that I want to remove the tint from the first(home) button if I click the other button...any pointers?

 

 

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

TweenPlugin.activate([TintPlugin]);

//Array to hold all the button instances.
var buttonArr:Array = new Array(home_btn,oferta_btn);

//Loop through all the button instance using the ‘for loop’.
for (var i =0; i < buttonArr.length; i++) {
   buttonArr[i].addEventListener(MouseEvent.CLICK, tint);
   buttonArr[i].addEventListener(MouseEvent.MOUSE_DOWN, noTint);
   buttonArr[i].buttonMode = true;
}

//Function to create  effect.
function tint(event:MouseEvent):void {
TweenLite.to(event.currentTarget, 1, {tint:0xff0000, ease:Expo.easeIn});
}

//Function to remove  effect.
function noTint(event:MouseEvent):void {
TweenLite.to(event.currentTarget, 1, {removeTint:true});
}

home_btn.addEventListener(MouseEvent.CLICK,home);
oferta_btn.addEventListener(MouseEvent.CLICK,oferta);

home_btn.buttonMode = true;
oferta_btn.buttonMode = true;


  // the stop action is here, and not inside the movieclip

home_btn.stop();   
home_btn.addEventListener(MouseEvent.CLICK, home);

function home(evt:MouseEvent):void {
  home_btn.play();
  home_btn.addEventListener(Event.ENTER_FRAME, homeLink);
}

function homeLink(evt:Event):void {
  if ( home_btn.currentFrame== home_btn.totalFrames) {
     home_btn.gotoAndStop(1);   // 'rewinds'  the buton/clip back to it's original state. use frame-labels if desired
     navigateToURL(new URLRequest("index.php"),"_self");
    home_btn.removeEventListener(Event.ENTER_FRAME, homeLink);
  }
}

oferta_btn.stop();   
oferta_btn.addEventListener(MouseEvent.CLICK, oferta);

function oferta(evt:MouseEvent):void {
  oferta_btn.play();
  oferta_btn.addEventListener(Event.ENTER_FRAME, ofertaLink);



}

function ofertaLink(evt:Event):void {
  if ( oferta_btn.currentFrame== oferta_btn.totalFrames) {
     oferta_btn.gotoAndStop(1);   // 'rewinds'  the buton/clip back to it's original state. use frame-labels if desired
     navigateToURL(new URLRequest("oferta.php"),"_self");
    oferta_btn.removeEventListener(Event.ENTER_FRAME, ofertaLink);
  }
}

Link to comment
Share on other sites

Removes tint from all other buttons:

function tint(event:MouseEvent):void {
for (var i =0; i < buttonArr.length; i++) {
	TweenLite.to(buttonArr[i], 1, {removeTint:true, ease:Expo.easeIn});
}
TweenLite.to(event.currentTarget, 1, {tint:0xff0000, ease:Expo.easeIn}); // overrides the tween from the loop that would remove this tint.
}

OR to just remove tint from the home_btn:

function tint(event:MouseEvent):void {
TweenLite.to(home_btn, 1, {removeTint:true, ease:Expo.easeIn}); // there's no harm in calling removeTint when no tint is applied
TweenLite.to(event.currentTarget, 1, {tint:0xff0000, ease:Expo.easeIn});
}

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