Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //TFTEXT
- package;
- import flash.text.TextField;
- public class TFText extends TextField
- {
- public function die():Void
- {
- if (parent != null) { parent.removeChild(this); }
- this.
- }
- }
- //CLICKTEXT
- package;
- public class ClickText extends TFText
- {
- public function clicked():Bool
- {
- if (parent == null) { return false; }
- else
- {
- return (mouseX > 0 && mouseY > 0 && mouseX < width && mouseY < height);
- }
- }
- }
- //CLICKMENU
- package;
- import flash.display.Sprite;
- import flash.Vector;
- import flash.text.TextFormat;
- import flash.text.TextFieldAutoSize;
- public class ClickMenu extends Sprite
- {
- private var texts:Vector<ClickText>;
- public function new (options:Vector<String>, format:TextFormat, spacing:Int, width:Int = 100)
- {
- texts = new Vector<ClickText>(options.length);
- for (i in 0...options.length)
- {
- texts[i] = new ClickText();
- texts[i].defaultTextForamt = format;
- texts[i].text = options[i];
- texts[i].y = i * spacing;
- texts[i].height = texts[i].textHeight;
- texts[i].width = width;
- //if that doesn't work
- //texts[i].autoSize = TextFieldAutoSize.LEFT;
- addChild(texts[i]);
- }
- }
- public function clicked():Int
- {
- if (parent == null) { return -1; }
- for (i in 0...texts.length)
- {
- if (texts[i].clicked()) { return i; }
- }
- return -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement