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.");
}
}
}
Unlike MovieClip symbols, which are dynamic, a SimpleButton object is not dynamic and has limited properties... a TextField is not one of them. Your best bet is to create the buttons as movieclips symbols. Then you will be able to target any object within it and manipulate the different states more freely.
North America
Europe, Middle East and Africa
Asia Pacific