Creating a text field in actionscript 3
So the Flash developers said, “Hey! Dragging and dropping text is waay too easy. Can’t we just make it harder?”
So they devised a really hard way to do it. As follows:
package {
import flash.display.Sprite;
import flash.text.TextField;
public class TextField_condenseWhite extends Sprite {
public function TextField_condenseWhite() {
var tf1:TextField = createTextField(0, 0, 200, 50);
tf1.condenseWhite = false;
tf1.htmlText = "keep on\n\ttruckin'";
var tf2:TextField = createTextField(0, 120, 200, 50);
tf2.condenseWhite = true;
tf2.htmlText = "keep on\n\ttruckin'";
}
private function createTextField(x:Number, y:Number, width:Number, height:Number):TextField {
var result:TextField = new TextField();
result.x = x;
result.y = y;
result.width = width;
result.height = height;
result.border = true;
addChild(result);
return result;
}
}
}
Reference:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html
Posted: May 30th, 2008 | Author: admin | Filed under: Code Reference | No Comments »


Recent Comments