Quick Tip: Check Flash Player Version Using ActionScript 3

In this Quick Tip, I’ll show you how to get and display the Flash Player Version using ActionScript. Let’s take a look!


Final Result Preview

Here’s the final result we will be working towards:


Step 1: Brief Overview

Using the Capabilities class, we’ll get the Flash Player version and Operating System then display them in a series of TextFields.


Step 2: Set Up Your Flash File

Launch Flash and create a new Flash Document.

Set the stage size to 300×100px.


Step 3: Interface

This is the interface we’ll be using, a simple background with six TextFields, three static, three dynamic. Don’t forget to add the instance names shown in the image.


Step 4: ActionScript

This is the class that does the work, it’s basically a common class structure, the constructor sets the Capabilities returned values to the TextFields in stage.

package
{
	import flash.display.Sprite;
	import flash.system.Capabilities;

	public class Main extends Sprite
	{
		public function Main():void
		{
			playerVersion.text = Capabilities.version;
			osVersion.text = Capabilities.os;

			/* This is a shorthand if statement, the regular if would look like this:

			if(Capabilities.isDebugger == true)
			{
				debugger.text = "Yes";
			}
			else
			{
				debugger.text = "No";
			}
			*/

			debugger.text = Capabilities.isDebugger ? "Yes" : "No";
		}
	}
}

Step 5: Document Class

Remember to add the class name to the Class field in the Publish section of the Properties panel.


Conclusion

Now you know how to check and display the Flash Player version, useful in many ways, especially if your application requires a newer version and you want to display a message to alert the user.

I hope you liked this Quick Tip, thank you for reading!

Leave a Reply

Your email address will not be published. Required fields are marked *