Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Title.as « actionscript « open-flash-chart « libs - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6086ff14f90c71f3ed264488c3dc78c2b67b4a1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
class Title
{
	public var mc:MovieClip;
	public var title:String = '';
	public var colour:Number;
	public var size:Number;
	private var top_padding:Number = 0;
	
	private var style:Css;
	
	function Title( lv:LoadVars )
	{
		if( lv.title == undefined )
			return;
			
		var tmp:Array = lv.title.split(',');
		
		this.style = new Css( tmp[1] );
		this.build( tmp[0] );
	}
	
	function build( text:String )
	{
		this.title = text;
		
		if( this.mc == undefined )
		{
			this.mc = _root.createEmptyMovieClip( "title", _root.getNextHighestDepth() );
			this.mc.txt = this.mc.createTextField( 'title', _root.getNextHighestDepth(), 0, 0, 200, 200 );
		}
			
		this.mc.txt.text = this.title;
		
		var fmt:TextFormat = new TextFormat();
		fmt.color = this.style.get( 'color' );
		fmt.font = "Verdana";
		fmt.size = this.style.get( 'font-size' );
		
		fmt.align = "center";
	
		this.mc.txt.setTextFormat(fmt);
		this.mc.txt.autoSize = "left";
		
		this.mc.txt._y = this.style.padding_top;
		this.mc.txt._x = this.style.padding_left;
		
		var height:Number = this.style.padding_top+this.mc.txt._height+this.style.padding_bottom;
		var width:Number = this.style.padding_left+this.mc.txt._width+this.style.padding_right;

		this.mc.beginFill( this.style.get( 'background-color' ), 100);
		this.mc.moveTo(0, 0);
		this.mc.lineTo(width, 0);
		this.mc.lineTo(width, height);
		this.mc.lineTo(0, height);
		this.mc.lineTo(0, 0);
		this.mc.endFill();
	}
	
	function move()
	{
		if( this.mc != undefined )
		{
			//
			// is the title aligned (text-align: xxx)?
			//
			var tmp:String = this.style.get( 'text-align' );
			switch( tmp )
			{
				case 'left':
					this.mc._x = this.style.get( 'margin-left' );
					break;
					
				case 'right':
					this.mc._x = Stage.width - ( this.mc._width + this.style.get( 'margin-right' ) );
					break;
					
				case 'center':
				default:
					this.mc._x = (Stage.width/2) - (this.mc._width/2);
					break;
			}
			
			this.mc._y = this.style.get( 'margin-top' );
		}
	}
	
	function height()
	{
		// the title may be turned off:
		if( this.mc == undefined )
			return 0;
		else
		{
			return this.style.padding_top+
				this.style.margin_top+
				this.mc.txt._height+
				this.style.padding_bottom+
				this.style.margin_bottom;
		}
	}
}