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?
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 );
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With