Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Type and Version of Browser from within Flash

I want to know the type and version the browser that the user is running from within my Flex 4 application. I know I can get that information by using ExternalInterface to call Javascript. I know I can get that information from the server.

I'm looking for a way to get that information directly from actionscript. I mean, isn't there a global variable or something that keeps this information?

like image 757
Jaffer Avatar asked Feb 19 '10 06:02

Jaffer


1 Answers

You can't since you don't have any global variables as you mention.

But whty not use ExternalInterface and JavaScript?.

var method:XML = <![CDATA[
     function( ){ 
         return { appName: navigator.appName, version:navigator.appVersion};}
    ]]>

var o:Object = ExternalInterface.call( method );
trace( "app name ",o.appName,"version ", o.version )

If you put it in a class as a static method, for you it would be as transparent as calling an intrinsic class...

package {
    import flash.external.ExternalInterface;


    public class BrowserUtils {

        private static const CHECK_VERSION:XML = <![CDATA[
             function( ) { 
                return { appName: navigator.appName, version:navigator.appVersion };
                }
            ]]>;

        public static function getVersion( ):Object {
            if ( !ExternalInterface.available ) return null;            

            return ExternalInterface.call( CHECK_VERSION );
        }

    }

}
like image 143
goliatone Avatar answered Nov 18 '22 17:11

goliatone