Hi,
Hi I am working with the Simplebutton class and a TextField for the button label. The Button works great except when I add the TextField. The problem is the TextField does not allow the rollovers of the SimpleButtoon class to work. Is there a way to the have the TextField on top of the SimpleButton but still have the roll overs work?
package {
import flash.display.Sprite;
import flash.events.*;
import fl.controls.Label;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.text.TextFieldType;
import flash.text.TextFormatAlign
public class CostumButton extends Sprite {
public function CostumButton(xLoc:Number, yLoc:Number, sTitle:String, tempSprite:Sprite, buttonRef) {
var bButton = new CustomSimpleButton(tempSprite);
bButton.x = xLoc;
bButton.y = yLoc;
bButton.addEventListener(MouseEvent.CLICK, buttonRef.handleClick)
addChild(bButton);
/*var simpleLabel:Label = new Label();
simpleLabel.move(xLoc, yLoc);
simpleLabel.text = sTitle;
simpleLabel.autoSize = TextFieldAutoSize.LEFT;
addChild(simpleLabel);*/
//create textField-------------------------
var tText:TextField = new TextField();
tText.x = xLoc;
tText.y = yLoc;
tText.width = bButton.width;
tText.selectable = false
//tText.autoSize = TextFieldAutoSize.LEFT;
var Format:TextFormat = new TextFormat();
//var FormatAlign = new TextFormatAlign()
Format.font = "Arial";
Format.color = 0x000000;
Format.size = 18;
Format.bold = false;
Format.align = TextFormatAlign.CENTER;
tText.defaultTextFormat = Format;
tText.text = sTitle;
addChild(tText)
}
}
}
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.display.Shape;
import flash.display.SimpleButton;
class CustomSimpleButton extends SimpleButton {
private var upColor:uint = 0xFFCC00;
private var overColor:uint = 0xCCFF00;
private var downColor:uint = 0x00CCFF;
private var size:uint = 80;
public function CustomSimpleButton(tempSprite:Sprite) {
downState = tempSprite;
overState = tempSprite
upState = tempSprite
hitTestState = tempSprite
// hitTestState.x = -(size / 4);
//hitTestState.y = hitTestState.x;
useHandCursor = true;
}
}
Thanks,
waffe