如何使用ActionScript来检测用户的操作系统种类及浏览器类型

检测用户的操作系统的代码

package

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

    public class VarTest extends Sprite
    {
        public 
function  VarTest()
        {
            super();
            graphics.lineStyle(
3 , 9 , 1 );
            
var  os:String  = flash.system.Capabilities.os.substr( 0 , 3 );
            
if  (os  ==   " Win " ) {
              
//  Windows-specific code goes here
            graphics.lineTo( 100 , 300 );
            } 
else   if  (os  ==   " Mac " ) {
              
//  Mac-specific code goes here
              graphics.lineTo( 500 , 200 );
            } 
else  {
              
//  Must be Unix or Linux
            }
        }
        
    }

}

检测用户浏览器的代码

   var playType:String=flash.system.Capabilities.playerType;

   if(playType=="Plugin")

   {

    //do actions for mozilla,etc.browser

    graphics.beginFill(0xff0000);

    graphics.drawRect(0,0,30,30);

    graphics.endFill();

   }

   else if(playType=="ActiveX")

   {

    //do actions for ie

    graphics.beginFill(0x00ff00);

    graphics.drawRect(50,50,40,40);

    graphics.endFill();

   }

   else

   {

    //do actions from no browser

   }     

 


 

你可能感兴趣的:(actionscript)