AS3 Get Flash Player Version Number (inc. Major and Minor Numbers)


/ Published in: ActionScript 3
Save to your folder(s)

This code separates out the Flash Player Platform, Major Version number and Minor Version numbers.


Copy this code and paste it in your HTML
  1. import flash.system.Capabilities;
  2.  
  3. var flashPlayerMajorVersion:int;
  4.  
  5. trace("Getting Flash Player version ...");
  6. var versionString:String = Capabilities.version;
  7. var pattern:RegExp = /^(\w*) (\d*),(\d*),(\d*),(\d*)$/;
  8. var result:Object = pattern.exec(versionString);
  9. if (result != null) {
  10. trace("input: " + result.input);
  11. trace("platform: " + result[1]);
  12. flashPlayerMajorVersion = int(result[2]);
  13. trace("flashPlayerMajorVersion: " + flashPlayerMajorVersion);
  14. trace("minorVersion: " + result[3]);
  15. trace("buildNumber: " + result[4]);
  16. trace("internalBuildNumber: " + result[5]);
  17. } else {
  18. trace("Unable to match RegExp.");
  19. }
  20.  
  21. // Example output ...
  22. //
  23. // Getting Flash Player version ...
  24. // input: WIN 10,1,52,14
  25. // platform: WIN
  26. // flashPlayerMajorVersion: 10
  27. // minorVersion: 1
  28. // buildNumber: 52
  29. // internalBuildNumber: 14

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.