вот нашел что нужно

Код AS3:
package {
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
public class MyButton extends SimpleButton {
public static const OVER_COLOR:uint = 0x999999;
public static const UP_COLOR:uint = 0x666666;
public static const DOWN_COLOR:uint = 0x886600;
private var _label:String;
public function MyButton(label:String):void {
_label = label;
downState = createSprite(DOWN_COLOR);
overState = createSprite(OVER_COLOR);
upState = createSprite(UP_COLOR);
hitTestState = overState;
}
private function createSprite(color:uint):Sprite {
var s:Sprite = new Sprite();
s.graphics.beginFill(color);
s.graphics.drawRoundRect(0, 0, 100, 18, 10, 10);
s.graphics.endFill();
var lab:TextField = createLabel();
lab.x = Math.round(s.width * .5 - lab.width * .5);
lab.y = Math.round(s.height * .5 - lab.height * .5);
s.addChild(lab);
return s;
}
private function createLabel():TextField {
var fmt:TextFormat = new TextFormat("_sans", 11);
var tf:TextField = new TextField();
tf.selectable = false;
tf.mouseEnabled = false;
tf.autoSize = TextFieldAutoSize.LEFT;
tf.defaultTextFormat = fmt;
tf.text = _label;
return tf;
}
}
}
создаю на главной

Код AS3:
import files.btnClass
var btn:MyButton = new MyButton('text btn');
btn.x = 10;
btn.y = 10;
addChild(btn);
пишет что
Цитата:
1046: Type was not found or was not a compile-time constant: MyButton.
1180: Call to a possibly undefined method MyButton.
|
вроде все делаю правильно. подскажите пожалуйста в чем моя ошибка. спасибо