Skip navigation
Currently Being Moderated

Changing the Color of Button Text

Jul 30, 2012 1:14 PM

Tags: #cs5.5 #button #actionscript3 #textfield #button_text #settextformat

Hi, Gang!

 

I'm looking to change the color of the text in my buttons, and looking to incorporate it into the following loop. Here's what I have, which produces Error #1069: Property TextField not found on flash.display.SimpleButton and there is no default value. at ....frame1:16]

 

When the user navigates to a page (e.g. CONTACT), I want the text for the contact button to be colored #714417.

 

How would I incorporate the change in text color into the array/ loop?

 

 

import flash.text.TextField;
import flash.text.TextFormat;

var buttonUpFormat:TextFormat = new TextFormat();
buttonUpFormat.color = 0x714417;

var buttonDownFormat:TextFormat = new TextFormat();
buttonDownFormat.color = 0xFFFFFF;

// Disable the HOME button
// and set the color of the button's text to #714417.

mainNav_mc.home_btn.mouseEnabled = false;
mainNav_mc.home_btn.TextField.setTextFormat (buttonUpFormat)//LINE 16 ERROR-PRODUCING CODE HERE.

// Create and array of the buttons
// and their destination.
var clipArray:Array = [mainNav_mc.home_btn, mainNav_mc.band_btn, mainNav_mc.events_btn, mainNav_mc.store_btn, mainNav_mc.contact_btn,];
var destArray:Array = ["home", "band", "events", "store", "contact"];

// Add function "clickHandler" to each of the buttons.
for (var i:int = 0; i < clipArray.length; i++) {
          clipArray[i].addEventListener(MouseEvent.CLICK, clickHandler);
}

// Disable the destination button,
// while re-enabling the other buttons.
// Set the opacity of the destination button to 100%,
// and the opacity of the other buttons to 30%;
function clickHandler(event:MouseEvent):void {
          for (var i:int = 0; i < clipArray.length; i++) {
                    if (event.currentTarget == clipArray[i]) {
                              this.gotoAndStop(destArray[i]);
                              clipArray[i].mouseEnabled = false;
                              clipArray[i].alpha = 1;
//                              clipArray[i].setTextFormat (buttonUpFormat);
//                              trace(event.target.name + " is disabled.");
                    }
                    else {
                              clipArray[i].mouseEnabled = true;
                              clipArray[i].alpha = .3;
//                              trace (clipArray[i] + " is enabled.");
                    }
          }
}






 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points