forked from: Testing the versions of Flash Player and SWF

by chez_sugi forked from Testing the versions of Flash Player and SWF (diff: 1)
♥0 | Line 42 | Modified 2012-09-25 16:30:15 | MIT License
play

ActionScript3 source code

/**
 * Copyright chez_sugi ( http://wonderfl.net/user/chez_sugi )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/oYfJ
 */

// forked from Fumio's Testing the versions of Flash Player and SWF
package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.utils.getTimer;
    import flash.system.Capabilities;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;
    [SWF(width = "240",height = "180")]
    public class FlashVersion extends Sprite {
        private var my_txt:TextField = new TextField();
        private var label_txt:TextField = new TextField();
        private var my_fmt:TextFormat = new TextFormat();
        public function FlashVersion() {
            // Creating a TextField for display
            createTextField();
            // Starting Test
            testVersion();
        }
        private function testVersion():void {
            var version_str:String = Capabilities.version;
            loaderInfo.addEventListener(Event.COMPLETE, getSwfVersion);
            xTrace("player", version_str);
        }
        private function getSwfVersion(eventObject:Event):void {
            var nSwfVersion:uint = loaderInfo.swfVersion
            xTrace("swf", String(nSwfVersion));
        }
        private function createTextField():void {
            addChild(my_txt);
            addChild(label_txt);
            my_fmt.align = TextFormatAlign.RIGHT;  
            my_txt.x +=  50;
            my_txt.defaultTextFormat = my_fmt;
            my_txt.autoSize = TextFieldAutoSize.RIGHT;
            label_txt.autoSize = TextFieldAutoSize.LEFT;
        }
        private function xTrace(label_str:String, _str:String):void {
            my_txt.appendText(_str + "\n");
            label_txt.appendText((label_str + ":" + "\n"));
        }
    }
}