AS3 - Detecting the current runtime environment PDF Print E-mail
Sunday, 19 June 2011 14:38

Knowing on which type of player (runtime environment) our game  is running can lead to interesting features, sometimes.

To check that, we can use the static playerType property of the Capabilities class. It gives a String, with one of the following values:

  • "External" - While testing the movie
  • "StandAlone" - Running on a stand-alone player, such as a Flash Projector
  • "ActiveX" - Running on Internet Explorer
  • "PlugIn" - Running on the Flash Player Browser Plug-in (Firefox, Safari, etc.)
  • "Desktop" - Running on the Adobe AIR runtime

For example, let's put a dynamic TextField on your stage and call it "playerCheck_txt", without quotes.

Then, create your document class, name it MyMain and write this piece of code:


	

	package{

	   

	    import flash.display.Sprite;

	

	    import flash.system.Capabilities;

	

	    public class MyMain extends Sprite{

	

	        function MyMain(){

	            playerCheck_txt.text= Capabilities.playerType;

	        }

	    

	    }

	}

	

	 

And, as a result, you will get this one:

 

Add comment


Security code
Refresh