
Posted by Matthew David
If you have been working with Flash MX you will know that some things work with different versions of the Flash Player. For instance, with the third release of the Flash 6 Player you can detect the ID3 tags in MP3 files (ID3 tags store information such as artist, album and song title). With this script you can detect which version of the Flash Player your user has to best optimize their experience when surfing your web site.
How do you program to these different versions? Fortunately, the changes are slight, but if you want to leverage new features such as MP3 ID3 tag reading, then you will need to know which version is which. For this, I have this following ActionScript that you can use to detect your code:
_global.flashVersion = {versionString:getVersion()};
flashVersion.toString = function() {
return this.versionString;
};
var foo = flashVersion.versionString.split(" ");
flashVersion.platform = foo[0];
foo = foo[1].split(",");
flashVersion.majorVersion = Number(foo[0]+"."+foo[1]);
flashVersion.minorVersion = Number(foo[2]+"."+foo[3]);
trace("majv : "+flashVersion.majorVersion);
trace("minv : "+flashVersion.minorVersion);
trace("platform : "+flashVersion.platform);
trace("vers string: "+flashVersion);
if (flashVersion.minorVersion>=60) {
flashVer = "You have the correct version of the Flash player installed";
trace(flashVer);
} else if (flashVersion.minorVersion<=59) {
flashVer = "To view Flash Communication Server Applications \nyou must be runnning Flash Player 6, \nrelease verion 60 or higher.";
trace(flashVer);
}
createTextField("mytext", 1, 100, 100, 400, 200);
mytext.multiline = true;
mytext.wordWrap = true;
mytext.border = false;
myformat = new TextFormat();
myformat.color = 0x000000;
myformat.bullet = false;
myformat.underline = false;
myformat.font = "_sans";
mytext.text = "majv : "+flashVersion.majorVersion+"\nminv : "+flashVersion.minorVersion+"\nplatform : "+flashVersion.platform+"\nvers string: "+flashVersion+"\n"+flashVer;
mytext.setTextFormat(myformat);
Simply paste this code into the first frame of a movie. You will not need to do anything else on the stage. Preview your movie and you will be told which version of Flash you are using. Now that you know which version of Flash you are using you can set up a Switch Statement, or an If/Else If statement, to redirect the user to different Flash Movies.