source: code/Website/open-flash-chart/elements/labels/YLegendBase.as@ 7849

Last change on this file since 7849 was 7849, checked in by dennisw, 15 years ago
File size: 2.1 KB
Line 
1package elements.labels {
2 import org.flashdevelop.utils.FlashConnect;
3 import flash.display.Sprite;
4 import flash.display.Stage;
5 import flash.text.*;
6 import flash.events.Event;
7 import flash.text.TextFieldAutoSize;
8 import flash.display.Loader;
9 import flash.events.Event;
10 import flash.net.URLRequest;
11 import string.Utils;
12 import string.Css;
13
14
15 public class YLegendBase extends Sprite {
16
17 public var tf:TextField;
18
19 public var text:String;
20 public var style:String;
21 private var css:Css;
22
23// [Embed(source = "C:\\Windows\\Fonts\\Verdana.ttf", fontFamily = "foo", fontName = '_Verdana')]
24// private static var EMBEDDED_FONT:String;
25
26// [Embed(systemFont='Arial', fontName='spArial', mimeType='application/x-font')]
27// public static var ArialFont:Class;
28
29 [Embed(systemFont='Arial', fontName='spArial', mimeType='application/x-font')]
30 public static var ArialFont:Class;
31
32 public function YLegendBase( json:Object, name:String )
33 {
34
35 if( json[name+'_legend'] == undefined )
36 return;
37
38 if( json[name+'_legend'] )
39 {
40 object_helper.merge_2( json[name+'_legend'], this );
41 }
42
43 this.css = new Css( this.style );
44
45 this.build( this.text );
46 }
47
48 private function build( text:String ): void {
49 var title:TextField = new TextField();
50
51 title.x = 0;
52 title.y = 0;
53
54 var fmt:TextFormat = new TextFormat();
55 fmt.color = this.css.color;
56 fmt.font = "spArial";
57 fmt.size = this.css.font_size;
58 fmt.align = "center";
59
60 title.htmlText = text;
61 title.setTextFormat(fmt);
62 title.autoSize = "left";
63 title.embedFonts = true;
64 title.rotation = 270;
65 title.height = title.textHeight;
66 title.antiAliasType = AntiAliasType.ADVANCED;
67 title.autoSize = TextFieldAutoSize.LEFT;
68
69 this.addChild(title);
70 }
71
72 public function resize():void {
73 if ( this.text == null )
74 return;
75 }
76
77 public function get_width(): Number {
78 if( this.numChildren == 0 )
79 return 0;
80 else
81 return this.getChildAt(0).width;
82 }
83
84 public function die(): void {
85
86 while ( this.numChildren > 0 )
87 this.removeChildAt(0);
88 }
89 }
90}
Note: See TracBrowser for help on using the repository browser.