forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstyleFields.as
More file actions
38 lines (37 loc) · 1.21 KB
/
styleFields.as
File metadata and controls
38 lines (37 loc) · 1.21 KB
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
package utils.textField
{
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.text.StyleSheet;
import flash.text.TextField;
/**
* Apply the application stylesheet to a <code>TextField</code> or to all <code>TextField</code>'s in a <code>DisplayObjectContainer</code>.
*
* <p><b>Warning</b>: Unlike <code>formatFields</code> you must <i>reset</i> your <code>htmlText</code> to have the style applied.</p>
* @param o <code>DisplayObject</code> that either <i>is</i> or contains <code>TextField</code>'s.
* @param stylesheet to apply to the <code>TextField</code>'s (Default: <code>App.css</code>).
* @see sekati.core.App#css
*/
public function styleFields(o:DisplayObject, stylesheet:StyleSheet):void
{
var tf:TextField;
var css:StyleSheet = stylesheet;
if (o is TextField)
{
tf = o as TextField;
tf.styleSheet = css;
}
else if (o is DisplayObjectContainer)
{
var container:DisplayObjectContainer = o as DisplayObjectContainer;
for (var i:int = 0; i < container.numChildren; i++)
{
if (container.getChildAt(i) is TextField)
{
tf = container.getChildAt(i) as TextField;
tf.styleSheet = css;
}
}
}
}
}