Parent Directory
|
Revision Log
Revision 1.2 - (view) (download)
| 1 : | dservos | 1.2 | /////////////////////////////////////////////////////////////////////////// |
| 2 : | // // | ||
| 3 : | // NOTICE OF COPYRIGHT // | ||
| 4 : | // // | ||
| 5 : | // Moodle - Modular Object-Oriented Dynamic Learning Environment // | ||
| 6 : | // http://moodle.org // | ||
| 7 : | // // | ||
| 8 : | // Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com // | ||
| 9 : | // // | ||
| 10 : | // This program is free software; you can redistribute it and/or modify // | ||
| 11 : | // it under the terms of the GNU General Public License as published by // | ||
| 12 : | // the Free Software Foundation; either version 2 of the License, or // | ||
| 13 : | // (at your option) any later version. // | ||
| 14 : | // // | ||
| 15 : | // This program is distributed in the hope that it will be useful, // | ||
| 16 : | // but WITHOUT ANY WARRANTY; without even the implied warranty of // | ||
| 17 : | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // | ||
| 18 : | // GNU General Public License for more details: // | ||
| 19 : | // // | ||
| 20 : | // http://www.gnu.org/copyleft/gpl.html // | ||
| 21 : | // // | ||
| 22 : | /////////////////////////////////////////////////////////////////////////// | ||
| 23 : | |||
| 24 : | dservos | 1.1 | package { |
| 25 : | import flash.display.SimpleButton; | ||
| 26 : | import flash.text.TextField; | ||
| 27 : | import flash.text.TextFormat; | ||
| 28 : | |||
| 29 : | public class Button extends SimpleButton { | ||
| 30 : | private var upColor:uint = 0x9999FF; | ||
| 31 : | private var overColor:uint = 0xBABAFF; | ||
| 32 : | private var downColor:uint = 0xBBBBFF; | ||
| 33 : | private var fmt:TextFormat = new TextFormat("mono",12,0,null,null,null,null,null,"center"); | ||
| 34 : | dservos | 1.2 | private var buttonText:String; |
| 35 : | dservos | 1.1 | |
| 36 : | public var props:Object = new Object(); | ||
| 37 : | |||
| 38 : | public function Button(text:String) { | ||
| 39 : | dservos | 1.2 | buttonText = text; |
| 40 : | dservos | 1.1 | downState = new ButtonDisplayState(text, fmt, downColor); |
| 41 : | overState = new ButtonDisplayState(text, fmt, overColor); | ||
| 42 : | upState = new ButtonDisplayState(text, fmt, upColor); | ||
| 43 : | hitTestState = upState; | ||
| 44 : | useHandCursor = true; | ||
| 45 : | } | ||
| 46 : | dservos | 1.2 | |
| 47 : | public function set text(text:String):void { | ||
| 48 : | buttonText = text; | ||
| 49 : | ButtonDisplayState(downState).text = text; | ||
| 50 : | ButtonDisplayState(overState).text = text; | ||
| 51 : | ButtonDisplayState(upState).text = text; | ||
| 52 : | } | ||
| 53 : | |||
| 54 : | public function get text():String { | ||
| 55 : | return buttonText; | ||
| 56 : | } | ||
| 57 : | dservos | 1.1 | } |
| 58 : | } | ||
| 59 : | |||
| 60 : | import flash.display.Sprite; | ||
| 61 : | import flash.text.TextField; | ||
| 62 : | import flash.text.TextFormat; | ||
| 63 : | import flash.text.TextFieldAutoSize; | ||
| 64 : | import flare.display.TextSprite; | ||
| 65 : | |||
| 66 : | class ButtonDisplayState extends Sprite | ||
| 67 : | { | ||
| 68 : | private var bgColor:uint; | ||
| 69 : | private var w:uint; | ||
| 70 : | private var h:uint; | ||
| 71 : | dservos | 1.2 | private var buttonText:String; |
| 72 : | private var fmt:TextFormat; | ||
| 73 : | private var ts:TextSprite; | ||
| 74 : | dservos | 1.1 | |
| 75 : | public function ButtonDisplayState(text:String, fmt:TextFormat, bgColor:uint) { | ||
| 76 : | this.bgColor = bgColor; | ||
| 77 : | dservos | 1.2 | buttonText = text; |
| 78 : | this.fmt = fmt; | ||
| 79 : | this.ts = new TextSprite(text, fmt); | ||
| 80 : | |||
| 81 : | dservos | 1.1 | var tf:TextField = ts.textField; |
| 82 : | |||
| 83 : | w = tf.width = tf.textWidth + 6; | ||
| 84 : | h = tf.height = tf.textHeight + 4; | ||
| 85 : | ts.dirty(); | ||
| 86 : | |||
| 87 : | addChild(ts); | ||
| 88 : | draw(); | ||
| 89 : | } | ||
| 90 : | |||
| 91 : | private function draw():void { | ||
| 92 : | graphics.beginFill(bgColor, 0.6); | ||
| 93 : | graphics.lineStyle(1, 0x4444FF, 0.3, true); | ||
| 94 : | graphics.drawRoundRect(0, 0, w, h, 10, 10); | ||
| 95 : | graphics.endFill(); | ||
| 96 : | } | ||
| 97 : | dservos | 1.2 | |
| 98 : | public function set text(text:String):void { | ||
| 99 : | buttonText = text; | ||
| 100 : | ts.text = text; | ||
| 101 : | } | ||
| 102 : | dservos | 1.1 | } |
| Moodle CVS Admin | ViewVC Help |
| Powered by ViewVC 1.0.7 |