source: code/Website/open-flash-chart/elements/labels/BaseLabel.as

Last change on this file was 7849, checked in by dennisw, 15 years ago
File size: 1.7 KB
Line 
1/* */
2
3package elements.labels {
4
5 import flash.display.Sprite;
6 import flash.display.Stage;
7 import flash.text.TextField;
8 import flash.text.TextFieldType;
9 import flash.text.TextFormat;
10 import flash.events.Event;
11 import flash.text.TextFieldAutoSize;
12 import string.Css;
13
14
15 public class BaseLabel extends Sprite {
16 public var text:String;
17 protected var css:Css;
18 public var style:String;
19 protected var _height:Number;
20
21 public function BaseLabel() {}
22
23 protected function build( text:String ):void {
24
25 var title:TextField = new TextField();
26 title.x = 0;
27 title.y = 0;
28
29 this.text = text;
30
31 title.htmlText = this.text;
32
33 var fmt:TextFormat = new TextFormat();
34 fmt.color = this.css.color;
35 //fmt.font = "Verdana";
36 fmt.font = this.css.font_family?this.css.font_family:'Verdana';
37 fmt.bold = this.css.font_weight == 'bold'?true:false;
38 fmt.size = this.css.font_size;
39 fmt.align = "center";
40
41 title.setTextFormat(fmt);
42 title.autoSize = "left";
43
44 title.y = this.css.padding_top+this.css.margin_top;
45 title.x = this.css.padding_left+this.css.margin_left;
46
47// title.border = true;
48
49 if ( this.css.background_colour_set )
50 {
51 this.graphics.beginFill( this.css.background_colour, 1);
52 this.graphics.drawRect(0,0,this.css.padding_left + title.width + this.css.padding_right, this.css.padding_top + title.height + this.css.padding_bottom );
53 this.graphics.endFill();
54 }
55
56 this.addChild(title);
57 }
58
59 public function get_width():Number {
60 return this.getChildAt(0).width;
61 }
62
63 public function die(): void {
64
65 this.graphics.clear();
66 while ( this.numChildren > 0 )
67 this.removeChildAt(0);
68 }
69 }
70}
Note: See TracBrowser for help on using the repository browser.