[moodle] / contrib / plugins / grade / report / visual / flare_visualization / Button.as Repository:

Annotation of /contrib/plugins/grade/report/visual/flare_visualization/Button.as

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download)

1 : dservos 1.1 package {
2 :     import flash.display.SimpleButton;
3 :     import flash.text.TextField;
4 :     import flash.text.TextFormat;
5 :    
6 :     public class Button extends SimpleButton {
7 :     private var upColor:uint = 0x9999FF;
8 :     private var overColor:uint = 0xBABAFF;
9 :     private var downColor:uint = 0xBBBBFF;
10 :     private var fmt:TextFormat = new TextFormat("mono",12,0,null,null,null,null,null,"center");
11 :    
12 :     public var props:Object = new Object();
13 :    
14 :     public function Button(text:String) {
15 :     downState = new ButtonDisplayState(text, fmt, downColor);
16 :     overState = new ButtonDisplayState(text, fmt, overColor);
17 :     upState = new ButtonDisplayState(text, fmt, upColor);
18 :     hitTestState = upState;
19 :     useHandCursor = true;
20 :     }
21 :     }
22 :     }
23 :    
24 :     import flash.display.Sprite;
25 :     import flash.text.TextField;
26 :     import flash.text.TextFormat;
27 :     import flash.text.TextFieldAutoSize;
28 :     import flare.display.TextSprite;
29 :    
30 :     class ButtonDisplayState extends Sprite
31 :     {
32 :     private var bgColor:uint;
33 :     private var w:uint;
34 :     private var h:uint;
35 :    
36 :     public function ButtonDisplayState(text:String, fmt:TextFormat, bgColor:uint) {
37 :     this.bgColor = bgColor;
38 :    
39 :     var ts:TextSprite = new TextSprite(text, fmt);
40 :     var tf:TextField = ts.textField;
41 :    
42 :     w = tf.width = tf.textWidth + 6;
43 :     h = tf.height = tf.textHeight + 4;
44 :     ts.dirty();
45 :    
46 :     addChild(ts);
47 :     draw();
48 :     }
49 :    
50 :     private function draw():void {
51 :     graphics.beginFill(bgColor, 0.6);
52 :     graphics.lineStyle(1, 0x4444FF, 0.3, true);
53 :     graphics.drawRoundRect(0, 0, w, h, 10, 10);
54 :     graphics.endFill();
55 :     }
56 :     }

Moodle CVS Admin
ViewVC Help
Powered by ViewVC 1.0.7