Chapter 17 Example 14
♥0 |
Line 28 |
Modified 2009-06-29 16:53:21 |
MIT License
archived:2017-03-09 22:16:48
ActionScript3 source code
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5aNi
*/
package {
import flash.display.Sprite;
import flash.text.Font;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
public class ch17ex14 extends Sprite {
public function ch17ex14() {
var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
addChild(tf);
var fonts:Array = Font.enumerateFonts(true);
var found:Boolean = false;
for each (var font:Font in fonts) {
if (font.fontName.match(/^comic\b/i) != null) {
tf.defaultTextFormat = new TextFormat(font.fontName, 14);
tf.text = "Don't you love this font, " + font.fontName + "?!";
found = true;
break;
}
}
if (!found) {
tf.defaultTextFormat = new TextFormat("_typewriter");
tf.text = "Lucky you, no Comic Sans!";
}
}
}
}