-
Notifications
You must be signed in to change notification settings - Fork 92
/
OSData.as
57 lines (48 loc) · 1.52 KB
/
OSData.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// OSData.as
package {
import flash.display.Sprite;
import flash.text.Font;
import flash.text.FontType;
import flash.text.FontStyle;
import flash.external.ExternalInterface;
import flash.system.Capabilities;
public class OSData extends Sprite
{
public function OSData()
{
ExternalInterface.addCallback('getFonts', this.getDeviceFonts);
ExternalInterface.addCallback('getOS', this.getOS);
ExternalInterface.addCallback('getResolution', this.getResolution);
ExternalInterface.addCallback('getLanguage', this.getLanguage);
if (ExternalInterface.available) {
ExternalInterface.call("isConnected");
}
}
public function getDeviceFonts():Array
{
var embeddedAndDeviceFonts:Array = Font.enumerateFonts(true);
var deviceFontNames:Array = [];
for each (var font:Font in embeddedAndDeviceFonts)
{
if (font.fontType == FontType.EMBEDDED
|| font.fontStyle != FontStyle.REGULAR
)
continue;
deviceFontNames.push(font.fontName);
}
return deviceFontNames;
}
public function getOS():String
{
return Capabilities.os;
}
public function getResolution():Array
{
return [Capabilities.screenResolutionX,Capabilities.screenResolutionY];
}
public function getLanguage():String
{
return Capabilities.language;
}
}
}