SYSTEM INFORMATION as2 |
This short tutorial will show you how to get system information of your viewers via flash. Can be helpful if you want to get information about resolution,
OS version or enabled sound and adapt your flash project accordingly maybe for better performance or you just want some statistics about your visitors. At the end we should get something like this:
Since this is actionscript 2.0 project, we will need as2 document. All we need on stage is dynamic textfield. Select it and open properties. Under the Options tab you will see Variable. Set its value to info.
![]() Now select frame on timeline, open actions window (F9) and paste in this actionscript code: OS = System.capabilities.os; ScreenWidth = System.capabilities.screenResolutionX; ScreenHeight = System.capabilities.screenResolutionY; ScreenResolution = ScreenWidth + "x" + ScreenHeight; ScreenDPI = System.capabilities.screenDPI; if (System.capabilities.hasAudio == true) { AudioSupport = "yes"; } else { AudioSupport = "no"; } information = "System information:\n\nOperation system: " + OS + "\nScreen resolution: " + ScreenResolution + "\nScreen DPI: " + ScreenDPI + "\nSound support: " + AudioSupport + "\n"; Mic = Microphone.get(); if (Mic.name == undefined) { Devices += "Microfone: not found"; } else { Devices += "Microfone: " + Mic.name; } Devices += "\n"; Cam = Camera.get(); if (Cam.name == undefined) { Devices += "Web camera: not found"; } else { Devices += "Web camera: " + Cam.name; } info = information + Devices;
First 5 lines stores information about OS, screen resolution and screen DPI into their variables. Lines 6-10 checks if system has audio support and on line 11 are all those information stored into one variable.
Lines 15-29 stores information about microphone and web camera if they are connected and stores them into devices variable. The very last line sends all those information into dynamic textfield on the stage.
|