-
Notifications
You must be signed in to change notification settings - Fork 251
/
Copy pathTools.as
68 lines (57 loc) · 1.67 KB
/
Tools.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
58
59
60
61
62
63
64
65
66
67
68
package
{
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.external.ExternalInterface;
import flash.net.navigateToURL;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.system.Capabilities;
import flash.system.System;
public final class Tools
{
public static function get currentUrl():String
{
if (ExternalInterface.available)
{
return ExternalInterface.call('function(){return window.location.href}');
}
return null;
}
public static function isInteractiveFullscreenSupported():Boolean
{
var parts:Array = Capabilities.version.split(' ')[1].split(',');
var major:int = parts[0];
var minor:int = parts[1];
return (major > 11) || (major == 11 && minor > 2);
}
public static function shortLink(url:String, done:Function):void
{
var bitly:String = 'http://api.bitly.com/v3/shorten?login=nesbox&apiKey=R_6933c0180c526715fb29e12176373e46&format=json&longUrl=' + escape(url);
var loader:URLLoader = new URLLoader;
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, function(event:Event):void
{
var result:Object = JSON.parse(loader.data);
if(result.status_code == 200
&& result.data
&& result.data.url)
{
done(result.data.url);
return;
}
done(null);
});
loader.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void
{
done(null);
});
loader.load(new URLRequest(bitly));
}
public static function gotoNesboxPage():void
{
navigateToURL(new URLRequest('http://nesbox.github.io/emulator/'), '_blank');
}
}
}