Kuortti.2010-06-26Saaristoleiri-Uto-2008_177Nanbudo_WCh2006_076Kobe, Japan 2010-04-28South.Africa.Roadtrip.2007-08_216Jodo-Milano.2008-09_035Pakkas03Pitkanen_076Saaristoleiri-Uto-2008_180South.Africa.Roadtrip.2007-08_353Vesa-Rauttu-60v_1899Nanbudo_Norge2007-12_211Helsinki2005-10-15_16_042Inujima, Japan 2010-04-30Naginata Helsinki 2010-02-07 09Helsinki2005-10-15_16_019Saaristoleiri 2009-08 34Slovenia2009-04_658Osaka, Japan 2010-04-29Kobe, Japan 2010-05-01Oslo.Norway.2002.summer.034Kuortti.2010-06-26Nanbudo_Norge2007-12_038
Alcohol prep pad

A preparation pad moisturised with alcohol for cleaning the wheel brakes of a bicycle while installing new brake pads.

TextField autosizing options

Actionscript 3 in Flash player 9 has four different ways to automate the sizing of a text field depending of its contents. The following piece of code shows how each of these "TextFieldAutoSize" constants differ when set prior of setting the content of the text field.

The other constants tested here, the "TextFormatAlign", have no effect if the autosize is other than "none".

package {
    import flash.display.*;
    import flash.events.Event;
    import flash.text.*;

    [SWF( backgroundColor = '0x5B5B5B', frameRate = '33', width = '600', height = '400')]

    public class TextAutoSizing extends Sprite {
        private var median:Shape;

        private var autosizes:Array = [
            TextFieldAutoSize.CENTER,
            TextFieldAutoSize.LEFT,
            TextFieldAutoSize.NONE,
            TextFieldAutoSize.RIGHT
        ];

        private var alings:Array = [
            TextFormatAlign.CENTER,
            TextFormatAlign.JUSTIFY,
            TextFormatAlign.LEFT,
            TextFormatAlign.RIGHT
        ];

        public function TextAutoSizing() {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.quality = StageQuality.MEDIUM;
            this.loaderInfo.addEventListener(Event.INIT, init);
        }

        private function init(evt:Event):void {
            median = new Shape();
            median.x = stage.stageWidth / 2;
            addChild(median);

            var gra:Graphics = median.graphics;
            gra.lineStyle(2, 0x0066FF);
            gra.lineTo(0, stage.stageHeight);

            var k:uint = 0;
            for (var i:uint = 0; i < autosizes.length; i++) {
                for (var j:uint = 0; j < alings.length; j++) {
                    var field:TextField = createTextField(autosizes[i], alings[j]);
                    field.y = 24 * (k) + 10;
                    field.text = "This text field has autosize: " + field.autoSize + " and align: " + field.defaultTextFormat.align + ".";
                    addChild(field);
                    ++k;
                }
            }
        }

        private function createTextField(auto:String, align:String):TextField {
            var format:TextFormat = new TextFormat();
            format.align = align;
            format.color = 0x000000;
            format.size = 12;

            var field:TextField = new TextField();
            field.background = true;
            field.backgroundColor = 0xFFFFFF;
            field.border = true;
            field.borderColor = 0x000000;
            field.autoSize = auto;
            field.defaultTextFormat = format;
            field.type = TextFieldType.INPUT;
            field.x = median.x;
            return field;
        }
    }
}

The attached swf file is the output of the code.

TextAutoSizing.swf

Time: 23/12/2008 21:06

QR code for paazio.nanbudo.fi