When working on our avatar project, I recently faced a tricky problem: since we use some Flash Player 10 features (such as PixelBender filters), we had to target our swf to Flash Player 10. On the other hand, we still do not want to force our users to install Flash Player 10. The decision was obvious: to make our application backward compatible – wherever we use a FP10 feature, we would also provide a simplified FP9 workaround.
My first approach to handle this backward compatibility issue was quite straightforward. I simply created a method that tests if the movie runs in Flash Player 10:
public static function isFlashPlayer10(): Boolean
{
var regExp: RegExp = /( )(?P<fpVersion>\d*)(,)/;
var fpVersion: int = int(regExp.exec(Capabilities.version).fpVersion);
return fpVersion >= 10;
}
And then I assumed, that the following code would solve my problem:
if (Utils.isFlashPlayer10())
{
//fp10 implementation goes here …
var shader: Shader = new Shader(new BendShader());
}
else
{
//fp9 workaround goes here …
}
However, when I ran this movie in Flash Player 9, the player has thrown this exception:
VerifyError: Error #1014: Classflash.display::Shader could not be found.
After some research I’ve found the solution: if you don’t want your FP10 movie to crash in Flash Player 9, you have to put to all the FP10 functionality into a separate class, e.g. UtilsFp10(), so that no references to FP10 classes (such as Shader or ShaderFilter) occur anywhere else in your code. Referencing the UtilsFp10() class itself then causes no problems (although just for sure it’s wise to wrap the UtilsFp10() method calls into a try-catch block).
if (Utils.isFlashPlayer10())
{
//fp10 implementation goes here …
try
{
UtilsFp10.playPixelBenderEffect();
}
catch (err: Error) {};
}
else
{
//fp9 workaround goes here …
}
Currently rated 5.0 by 1 people
- Currently 5/5 Stars.
- 1
- 2
- 3
- 4
- 5