« The ... Parameter | Main | Core Display Classes Part2 »

Core Display Classes Part1

Vector Graphics
Each Shape, Sprite, and MovieClip object has a graphic property. The graphics property is a Graphic object. The graphics layer for a Sprite or MovieClip does not appear in the child list of them.

import flash.display.*;
var circle:Shape = new Shape();
circle.graphics.drawCircle(x, y, r);
this.addChild(circle);

Text
The TextField class let you work with dynamic and input text fields. The StaticText class are only created in the Flash authoring tool. The TextFormat object can be used to set formatting for an entire TextField or for a range of text.

var tf:TextField = new TextField();
tf.text = "Hello";
var format:TextFormat = new TextFormat();
format.color = 0xff0000;
tf.setTextFormat(format);
addChild(tf);
var style:StyleSheet = new StyleSheet();
var styleObj:Object = new Object();
styleObj.fontSize = "bold";
style.setStyle(".bold", styleObj);
delete styleObj;

var tfHtml:TextField = new TextField();
tfHtml.styleSheet = style;
tfHtml.htmlText = "<span class='bold'></span>";
addChild(tfHtml);

Post a comment