Created
August 20, 2009 14:36
-
-
Save sixones/171098 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.sixones | |
{ | |
import flash.system.Capabilities; | |
/** | |
* Provides a static class with details of the current running Flash version. | |
* | |
* Usage: FlashVersion.getInstance() => # FlashVersion object instance | |
*/ | |
public class FlashVersion | |
{ | |
protected var _platform:String; | |
protected var _major:uint = 0; | |
protected var _minor:uint = 0; | |
protected var _build:uint = 0; | |
protected var _internalBuild:Number = 0; | |
private var _raw:String = ""; | |
private static var __instance:FlashVersion; | |
public function FlashVersion(block:FlashVersionBlocker) | |
{ | |
this._raw = Capabilities.version; | |
var pattern:RegExp = /^(\w*) (\d*),(\d*),(\d*),(\d*)$/; | |
var result:Object = pattern.exec(this._raw); | |
if (result != null) | |
{ | |
this._platform = String(result[1]); | |
this._major = Number(result[2]); | |
this._minor = Number(result[3]); | |
this._build = Number(result[4]); | |
this._internalBuild = Number(result[5]); | |
} | |
else | |
{ | |
trace('Failed to regex flash version'); | |
} | |
} | |
public function get platform():String | |
{ | |
return this._platform; | |
} | |
public function get major():uint | |
{ | |
return this._major; | |
} | |
public function get minor():uint | |
{ | |
return this._minor; | |
} | |
public function get build():uint | |
{ | |
return this._build; | |
} | |
public function get internalBuild():uint | |
{ | |
return this._internalBuild; | |
} | |
public function get raw():String | |
{ | |
return this._raw; | |
} | |
public function toString() : String | |
{ | |
return this.major+"."+this.minor+"."+this.build+" "+this.platform; | |
} | |
public static function getInstance():FlashVersion | |
{ | |
if (FlashVersion.__instance == null) | |
{ | |
FlashVersion.__instance = new FlashVersion(new FlashVersionBlocker()); | |
} | |
return FlashVersion.__instance; | |
} | |
} | |
} | |
class FlashVersionBlocker { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment