In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Justified text

Get Adobe Flash player
by lewis_c1986 07 Apr 2010
/**
 * Copyright lewis_c1986 ( http://wonderfl.net/user/lewis_c1986 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mxwD
 */

package {
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFieldType;

    import flash.text.TextFormat;
    public class TextField_alwaysShowSelection extends Sprite {
        public function TextField_alwaysShowSelection()
        {
            var label1:TextField = createCustomTextField(0, 20, 200, 112);
            label1.wordWrap = true;
            label1.multiline = true;
            var tmpFormat:TextFormat = label1.getTextFormat();
            tmpFormat.align = "justify";
            label1.defaultTextFormat = tmpFormat;
            label1.backgroundColor = 0x0099ff;
            label1.background = true;
            label1.htmlText = "This text is programmatically justified and it allows me to type whatever I like and have the text fully justified, also it's not stupid and so knows when text is too short and would look silly.\n\n-Lewis";
             //label1.setTextFormat(tmpFormat, 0, label1.text.length);
            label1.alwaysShowSelection = true;
		}

        private function createCustomTextField(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;
            addChild(result);
            return result;
        }
    }
}