{"id":670,"date":"2009-03-06T17:03:15","date_gmt":"2009-03-06T09:03:15","guid":{"rendered":"http:\/\/fdream.net\/blog\/article\/670.aspx"},"modified":"2009-03-06T18:03:14","modified_gmt":"2009-03-06T10:03:14","slug":"%e5%85%b6%e5%ae%9eAS%e5%92%8cJS%e4%ba%92%e7%9b%b8%e8%b0%83%e7%94%a8%e6%9c%89%e4%b8%aa%e5%be%88%e9%85%b7%e7%9a%84%e7%89%b9%e6%80%a7","status":"publish","type":"post","link":"https:\/\/fdream.net\/blog\/article\/670","title":{"rendered":"\u5176\u5b9eAS\u548cJS\u4e92\u76f8\u8c03\u7528\u6709\u4e2a\u5f88\u9177\u7684\u7279\u6027"},"content":{"rendered":"<p>JavaScript\u548cActionScript\u4e92\u76f8\u8c03\u7528\u65f6\uff0c\u5176\u5b9e\u6709\u4e2a\u975e\u5e38\u597d\u7684\u7279\u6027\uff0c\u4e0d\u8fc7\u8c8c\u4f3c\u5f88\u5c11\u6709\u4eba\u63d0\u5230\u8fd9\u4e2a\u7279\u6027\uff1a\u5b83\u4eec\u4e4b\u95f4\u7684\u6570\u636e\u7c7b\u578b\u5bf9\u65b9\u5747\u53ef\u4ee5\u8bc6\u522b\u3002\u56e0\u6b64\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7swf\u63d0\u4f9b\u7684\u63a5\u53e3\u6765\u4f20\u9012\u5bf9\u8c61\u3001\u6570\u7ec4\u3001\u5b57\u7b26\u4e32\u7b49\u7b49\u3002\u4e0d\u8fc7\u5b83\u4eec\u4e4b\u95f4\u4f20\u9012\u7684\u53c2\u6570\u7684\u503c\u7684\u957f\u5ea6\u6709\u9650\u5236\uff08\u5177\u4f53\u957f\u5ea6\u8fd8\u6ca1\u4ed4\u7ec6\u6d4b\u8bd5\uff09\uff0c\u56e0\u6b64\u4f60\u4e0d\u80fd\u628aJavaScript\u4e2d\u7684\u4e00\u4e2a\u8d85\u5927\u7684\u5bf9\u8c61\u76f4\u63a5\u4f20\u9012\u8fdb\u53bb\u3002\u4e0d\u8fc7\u5373\u4f7f\u662f\u8fd9\u6837\uff0c\u5df2\u7ecf\u975e\u5e38\u597d\u7528\u4e86\uff0c\u770b\u770b\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<p>AS(ActionScript)\u4ee3\u7801\uff1a<\/p>\n<p><pre lang=\"actionscript\">\n\/\/ \u521b\u5efa\u4e00\u4e2a\u884c\u7684TextField\u6765\u663e\u793a\u8c03\u7528\u7ed3\u679c\nvar t:TextField = new TextField();\nt.x = 10;\nt.y = 10;\nt.width = 300;\nt.height = 200; \nthis.addChild(t);\n\n\/\/ \u8fd9\u4e2a\u662f\u8981\u7ed9JavaScript\u8c03\u7528\u7684\u51fd\u6570\nfunction test(obj){\n    var s = [];\n    for(var p in obj){\n        s.push(p + ': ' + obj[p]);\n    }\n    t.text = s.join('\\r\\n');\n}\n\n\/\/ \u6dfb\u52a0\u8c03\u7528\u63a5\u53e3\nExternalInterface.addCallback(&quot;test&quot;, test);\nt.text = 'ready';\n\n\/\/ \u8c03\u7528JavaScript\uff0c\u544a\u8bc9JavaScript\u6211\u5df2\u7ecf\u51c6\u5907\u597d\u4e86\nExternalInterface.call('ready', {a:'a string', b:'string b'});\n<\/pre>\n<\/p>\n<p>JavaScript\u4ee3\u7801\uff1a<\/p>\n<p><pre lang=\"javascript\">\nvar swfId = 'call_swf'\nfunction ready(){\n    \/\/ \u83b7\u53d6flash\u4f20\u9012\u8fc7\u6765\u7684\u53c2\u6570\n    var o = arguments[0];\n    var s = [];\n    for(var p in o){\n        s.push([p, ': ', o[p]].join(''));\n    }\n    \/\/ \u6253\u5370\u4f20\u9012\u8fdb\u6765\u7684\u5bf9\u8c61\u7684\u5185\u5bb9\n    alert(s.join('\\n'));\n    \n    var swf = document[swfId] ? document[swfId] : window[swfId];\n    \/\/ \u8c03\u7528flash\u63d0\u4f9b\u7684\u63a5\u53e3\n    swf.test({a:'a string', b:'string b'});\n}\n<\/pre>\n<\/p>\n<p>\u4e0b\u9762\u8fd9\u4e2a\u662fAS2\u7684\u4ee3\u7801\uff1a<\/p>\n<p><pre lang=\"actionscript\">\nimport flash.external.*;\n\n\/\/ \u521b\u5efa\u4e00\u4e2a\u884c\u7684TextField\u6765\u663e\u793a\u8c03\u7528\u7ed3\u679c\nvar t:TextField = this.createTextField('t', this.getNextHighestDepth(), 10, 10, 300, 200); \nt.text = 'ready';\n\n\/\/ \u8fd9\u4e2a\u662f\u8981\u7ed9JavaScript\u8c03\u7528\u7684\u51fd\u6570\nfunction test(obj){\n    var s = [];\n    for(var p in obj){\n        s.push(p + ': ' + obj[p]);\n    }\n    t.text = s.join('\\r\\n');\n}\n\n\/\/ \u6dfb\u52a0\u8c03\u7528\u63a5\u53e3\nvar testsuc:Boolean = ExternalInterface.addCallback(&quot;test&quot;, null, test);\nt.text = ['test: ', testsuc].join('\\n');\n\n\/\/ \u8c03\u7528JavaScript\uff0c\u544a\u8bc9JavaScript\u6211\u5df2\u7ecf\u51c6\u5907\u597d\u4e86\nExternalInterface.call('ready', {a:'a string', b:'string b'});\n<\/pre>\n<\/p>\n<p>\u76f8\u4e92\u8c03\u6765\u8c03\u53bb\u662f\u4e0d\u662f\u5f88\u65b9\u4fbf\uff1f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript\u548cActionScript\u4e92\u76f8\u8c03\u7528\u65f6\uff0c\u5176\u5b9e\u6709\u4e2a\u975e\u5e38\u597d\u7684\u7279\u6027\uff0c\u4e0d\u8fc7\u8c8c\u4f3c\u5f88\u5c11\u6709\u4eba\u63d0\u5230\u8fd9\u4e2a\u7279\u6027\uff1a\u5b83\u4eec\u4e4b\u95f4\u7684\u6570\u636e\u7c7b\u578b\u5bf9\u65b9\u5747\u53ef\u4ee5\u8bc6\u522b\u3002\u56e0\u6b64\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7swf\u63d0\u4f9b\u7684\u63a5\u53e3\u6765\u4f20\u9012\u5bf9\u8c61\u3001\u6570\u7ec4\u3001\u5b57\u7b26\u4e32\u7b49\u7b49\u3002\u4e0d\u8fc7\u5b83\u4eec\u4e4b\u95f4\u4f20\u9012\u7684\u53c2\u6570\u7684\u503c\u7684\u957f\u5ea6\u6709\u9650\u5236\uff08\u5177\u4f53\u957f\u5ea6\u8fd8\u6ca1\u4ed4\u7ec6\u6d4b\u8bd5\uff09\uff0c\u56e0\u6b64\u4f60\u4e0d\u80fd\u628aJavaScript\u4e2d\u7684\u4e00\u4e2a\u8d85\u5927\u7684\u5bf9\u8c61\u76f4\u63a5\u4f20\u9012\u8fdb\u53bb\u3002\u4e0d\u8fc7\u5373\u4f7f\u662f\u8fd9\u6837\uff0c\u5df2\u7ecf\u975e\u5e38\u597d\u7528\u4e86\uff0c\u770b\u770b\u793a\u4f8b\u4ee3\u7801\uff1a AS(ActionScript)\u4ee3\u7801\uff1a \/\/ \u521b\u5efa\u4e00\u4e2a\u884c\u7684TextField\u6765\u663e\u793a\u8c03\u7528\u7ed3\u679c var t:TextField = new TextField(); t.x = 10; t.y = 10; t.width = 300; t.height = 200; this.addChild(t); \/\/ \u8fd9\u4e2a\u662f\u8981\u7ed9JavaScript\u8c03\u7528\u7684\u51fd\u6570 function test(obj){ var s = []; for(var p in obj){ s.push(p + &#8216;: &#8216; + obj[p]); } t.text = s.join(&#8216;\\r\\n&#8217;); } \/\/ \u6dfb\u52a0\u8c03\u7528\u63a5\u53e3 ExternalInterface.addCallback(&quot;test&quot;, test); t.text = &#8216;ready&#8217;; \/\/ \u8c03\u7528JavaScript\uff0c\u544a\u8bc9JavaScript\u6211\u5df2\u7ecf\u51c6\u5907\u597d\u4e86 ExternalInterface.call(&#8216;ready&#8217;, &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[216,78,298,104],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-coding","tag-ActionScript","tag-AS","tag-AS3","tag-JavaScript"],"views":5723,"_links":{"self":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":0,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/posts\/670\/revisions"}],"wp:attachment":[{"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fdream.net\/blog\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}