Cross Platform Flash AS3 CD-ROM ? Part 1

Having had some huge problems trying to get a cross platform CD to work correctly I decided to build a browser & platform detection function. Part 1 of the tutorial is all about detecting which platform you are on. Lets begin...

 var playerVersion:String = System.capabilities.version;
var playerType:String = System.capabilities.playerType;
var myLength:Number = length(playerVersion);
var platform:String;


function detectPlatform():Void {

var i:Number = 0;

while (i <= myLength) {
i = i + 1;
temp = substring(playerVersion, i, 1);
if (temp eq " ") {

platform = substring(playerVersion, 1, i-1);


If you run it now not much will happen but the trace should return the platform and the player type. Now that we have the details collected we can use the information to do platform and browser dependant actions. Add the code below and put the code in where the specific comments are and you should have a working example. You can remove or comment out the above traces.

 if (platform =="MAC") {
//mac code here
if (playerType == "StandAlone") {
//playing in standalone

} else if (playerType == "PlugIn"){
//playing in browser

} else {
//playing in other
//This could be in a test swf

} else if (platform == "WIN") {
//PC code here
if (playerType == "StandAlone") {
//playing in standalone on PC

} else if (playerType == "PlugIn"){
//playing in browser other than IE

} else if (playerType == "ActiveX"){
//playing in IE

} else {
//playing in other
//e.g. Test SWF on a PC

So there you have it. Use it how you want. The next part of this will show you how to open files on each platform using FSCommand and applescript.I built this code using the information and examples provided by and so the credit is due to them.

Published on


comments powered by Disqus