{"id":1525,"date":"2012-09-11T21:33:42","date_gmt":"2012-09-11T12:33:42","guid":{"rendered":"http:\/\/www23.atpages.jp\/~inoni\/?p=1525"},"modified":"2012-09-11T21:33:42","modified_gmt":"2012-09-11T12:33:42","slug":"actionscript3-0%e8%a6%9a%e6%9b%b8-%e3%83%96%e3%83%a9%e3%82%a6%e3%82%b6%e3%81%8b%e3%82%89air%e8%b5%b7%e5%8b%95","status":"publish","type":"post","link":"http:\/\/anada.cloudfree.jp\/?p=1525","title":{"rendered":"ActionScript3.0\u899a\u66f8 \u30d6\u30e9\u30a6\u30b6\u304b\u3089AIR\u8d77\u52d5"},"content":{"rendered":"<p>\u4e45\u3057\u3076\u308a\u306bActionScript\u3092\u3084\u3063\u305f\u3002<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30ed\u30fc\u30ab\u30eb\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308bAIR\u30a2\u30d7\u30ea\u3092\u8d77\u52d5\u3059\u308b\u65b9\u6cd5\u3002<br \/>\n\u8d77\u52d5\u6642\u306b\u30d6\u30e9\u30a6\u30b6\u3092\u9589\u3058\u308b\u51e6\u7406\u3092\u5165\u308c\u3066\u3044\u308b\u3051\u308c\u3069\u3001\u3053\u308c\u3060\u3068\u78ba\u8a8d\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u51fa\u3066\u304f\u308b\u306e\u3067\u3001\u5b9f\u969b\u306f\u5225\u306eJavaScript\u3092\u8aad\u3093\u3067\u3044\u308b\u3002<\/p>\n<p>launchApplication\u306f\u3001\u30de\u30a6\u30b9\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3068\u304b\u3067\u3057\u304b\u52d5\u304b\u306a\u3044\u3002<br \/>\ndispatchEvent\u3068\u304b\u3067\u30de\u30a6\u30b9\u30af\u30ea\u30c3\u30af\u30a4\u30d9\u30f3\u30c8\u3092\u7121\u7406\u3084\u308a\u547c\u3073\u51fa\u3057\u3066\u307f\u305f\u3051\u3069\u3001launchApplication\u3060\u3051\u52d5\u304b\u306a\u304b\u3063\u305f\u3002\uff08\u4ed6\u306e\u884c\u306f\u52d5\u3044\u3066\u3093\u306e\u306b\u3043\u30fb\u30fb\u30fb\uff09<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\npackage {\n\n\timport flash.net.URLRequest;\n\timport flash.display.Loader;\n\timport flash.display.LoaderInfo;\n\timport flash.system.LoaderContext;\n\timport flash.system.ApplicationDomain;\n\timport flash.events.Event;\n\timport flash.events.MouseEvent;\n\n\timport flash.text.TextField;\n\timport flash.text.TextFormat;\n\timport flash.display.Sprite;\n\timport flash.external.ExternalInterface;\n\timport flash.events.EventDispatcher;\n\n\t&#x5B;SWF(width=600,height=120,backgroundColor=0xffffff)]\n\tpublic class Main extends Sprite {\n\n\t\tprivate var air_url:URLRequest = new URLRequest(&quot;http:\/\/airdownload.adobe.com\/air\/browserapi\/air.swf&quot;);\n\t\tprivate var air_swf:Object = null;\n\t\tprivate var appID:String = &quot;xxxxxxxxxx&quot;;\n\t\tprivate var pubID:String = &quot;&quot;;\n\t\tprivate var args:Array;\n\t\tprivate var tx1:TextField = new TextField();\n\t\tprivate var btn:Sprite = new Sprite();\n\n\t\tpublic function Main() {\n\t\t\ttx1.defaultTextFormat = new TextFormat(&quot;&quot;, 12, 0x0033ff, true);\n\t\t\ttx1.autoSize = &quot;left&quot;;\n\t\t\ttx1.x = 0;\n\t\t\ttx1.y = 10;\n\t\t\ttx1.width = 600;\n\t\t\ttx1.selectable = false;\n\t\t\taddChild(tx1);\n\n\t\t\t\/\/ air.swf\u8d77\u52d5\n\t\t\tvar loader_obj:Loader = new Loader();\n\t\t\tvar info:LoaderInfo = loader_obj.contentLoaderInfo;\n\t\t\tvar loader_context:LoaderContext = new LoaderContext();\n\t\t\tloader_context.applicationDomain = ApplicationDomain.currentDomain;\n\t\t\tinfo.addEventListener(Event.INIT , loadInit);\n\t\t\tloader_obj.load(air_url,loader_context);\n\t\t}\n\n\t\t\/\/ \u521d\u671f\u72b6\u614b\n\t\tprivate function loadInit(e:Event):void {\n\t\tair_swf = e.target.content;\n\t\ttry {\n\t\t\ttx1.text = &quot;\u3057\u3070\u3089\u304f\u304a\u5f85\u3061\u304f\u3060\u3055\u3044\u3002&quot; ;\n\t\t\tair_swf.getApplicationVersion( appID, pubID, getVersion);\n\t\t} catch( err:Error ) {\n\t\t\ttx1.text = err.message ;\n\t\t}\n\t\t}\n\n\t\t\/\/ \u30d0\u30fc\u30b8\u30e7\u30f3\u78ba\u8a8d\n\t\tprivate function getVersion(version:String):void {\n\t\t\tif (version == null) {\n\t\t\t\ttx1.text = &quot;\u30a2\u30d7\u30ea\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002&quot; ;\n\t\t\t} else {\n\t\t\t\ttx1.text = &quot;\u4e0b\u306e\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u30a2\u30d7\u30ea\u3092\u8d77\u52d5\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot; ;\n\t\t\t\tbtn = createButton();\n\t\t\t\taddChild(btn);\n\t\t\t\tbtn.addEventListener(MouseEvent.CLICK,function(e:MouseEvent):void{\n\t\t\t\tair_swf.launchApplication( appID, pubID, args);\n\t\t\t\t\tExternalInterface.call(&quot;window.close()&quot;);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t\/\/ \u30dc\u30bf\u30f3\u751f\u6210\n\t\tprivate function createButton():Sprite{\n\t\t\tvar tx:TextField = new TextField();\n\t\t\tvar btn:Sprite = new Sprite();\n\n\t\t\ttx.width = 100;\n\t\t\ttx.defaultTextFormat = new TextFormat(&quot;&quot;, 20, 0xffffff, true);\n\t\t\ttx.text = &quot; \u8d77\u52d5 &quot;;\n\t\t\ttx.autoSize = &quot;center&quot;;\n\t\t\ttx.x = 0;\n\t\t\ttx.y = 8;\n\t\t\ttx.selectable = false;\n\t\t\tbtn.addChild(tx);\n\n\t\t\tbtn.graphics.lineStyle(1, 0xBBBBBB);\n\t\t\tbtn.graphics.beginFill(0x9933ff);\n\t\t\tbtn.graphics.drawRoundRect(0, 0, tx.width, 40, 20, 20);\n\t\t\tbtn.graphics.endFill();\n\t\t\tbtn.x = 100;\n\t\t\tbtn.y = 50;\n\t\t\treturn btn;\n\t\t}\n\t}\n}\n<\/pre>\n<p>appID\u306b\u306f\u8d77\u52d5\u3055\u305b\u308bAIR\u306e\u30a2\u30d7\u30eaID\u3092\u8a2d\u5b9a\u3002<br \/>\n\u307e\u305f\u3001\u8d77\u52d5\u6642\u306b\u5f15\u6570\u3092\u6e21\u3057\u305f\u3044\u3068\u304d\u306f\u3001launchApplication\u306e3\u3064\u3081\u306e\u5f15\u6570\u306b\u30bb\u30c3\u30c8\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>\u8d77\u52d5\u3055\u305b\u308bAIR\u5074\u306f\u3001\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u306e\u8d77\u52d5\u3092\u53ef\u80fd\u306b\u3059\u308b\u305f\u3081\u3001(xxx)-app.xml\u306eallowBrowserInvocation\u30bf\u30b0\u5185\u3092true\u306b\u30bb\u30c3\u30c8\u3057\u3066\u304a\u304f\u3002<\/p>\n<p>\u3000\uff1callowBrowserInvocation\uff1etrue\uff1c\/allowBrowserInvocation\uff1e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e45\u3057\u3076\u308a\u306bActionScript\u3092\u3084\u3063\u305f\u3002 \u30d6\u30e9\u30a6\u30b6\u304b\u3089\u30ed\u30fc\u30ab\u30eb\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u308bAIR\u30a2\u30d7\u30ea\u3092\u8d77\u52d5\u3059\u308b\u65b9\u6cd5\u3002 \u8d77\u52d5\u6642\u306b\u30d6\u30e9\u30a6\u30b6\u3092\u9589\u3058\u308b\u51e6\u7406\u3092\u5165\u308c\u3066\u3044\u308b\u3051\u308c\u3069\u3001\u3053\u308c\u3060\u3068\u78ba\u8a8d\u30c0\u30a4\u30a2\u30ed\u30b0\u304c\u51fa\u3066\u304f\u308b\u306e\u3067\u3001\u5b9f\u969b\u306f\u5225\u306eJa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1525","post","type-post","status-publish","format-standard","hentry","category-flashactionscript"],"_links":{"self":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts\/1525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1525"}],"version-history":[{"count":0,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts\/1525\/revisions"}],"wp:attachment":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1525"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}