{"id":466,"date":"2008-09-23T21:18:46","date_gmt":"2008-09-23T13:18:46","guid":{"rendered":""},"modified":"2010-02-12T12:50:03","modified_gmt":"2010-02-12T04:50:03","slug":"%e4%b8%80%e6%ae%b5%e7%b2%be%e8%87%b4%e7%9a%84loading%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/inhaoxu.com\/blog\/?p=466","title":{"rendered":"\u4e00\u6bb5\u7cbe\u81f4\u7684loading\u4ee3\u7801"},"content":{"rendered":"<p>\u5168\u90e8AS\u5b8c\u6210\u3002<\/p>\n<p>MovieClip.prototype.loadhere=function(x,y,path,name) {<br \/>\n\/\/ creates and positions clip, bar and text<br \/>\nvar containerText=name+&quot;text&quot;;<br \/>\nvar containerBar=name+&quot;bar&quot;;<br \/>\nthis.createEmptyMovieClip(name,1);<br \/>\nthis.createEmptyMovieClip(containerText,2);<br \/>\nthis.createEmptyMovieClip(containerBar,3);<br \/>\nthis[name]._x=x;<br \/>\nthis[name]._y=y;<br \/>\nthis[containerText]._x=x;<br \/>\nthis[containerText]._y=y;<br \/>\nthis[containerBar]._x=x;<br \/>\nthis[containerBar]._y=y;<br \/>\n<!--more-->\/\/ draws the bar<br \/>\nwith (this[containerBar]){<br \/>\nbeginFill (0xDDDDDD, 50);<br \/>\nlineStyle (1, 0x000000, 100);<br \/>\nmoveTo (0, 0);<br \/>\nlineTo (80, 0);<br \/>\nlineTo (80, 20);<br \/>\nlineTo (0, 20);<br \/>\nlineTo (0,0);<br \/>\nendFill();<br \/>\n}<br \/>\n\/\/ loads movie<br \/>\nthis[name].loadMovie(path);<br \/>\nvar movie=this[name];<br \/>\nvar prelText=this[containerText];<br \/>\nvar prelBar=this[containerBar];<br \/>\n\/\/ sets new text format<br \/>\nvar formtext=new TextFormat();<br \/>\nformtext.color=&quot;0x000000&quot;;<br \/>\nformtext.font=&quot;_sans&quot;;<br \/>\nformtext.align=&quot;center&quot;;<br \/>\nprelText.createTextField(&quot;loadtext&quot;,50,0,0,80,20);<br \/>\nprelText.loadtext.border=false;<br \/>\n\/\/ defines text display<br \/>\nprelText.onEnterFrame=function() {<br \/>\nif(this.percent!=100) {<br \/>\nthis.percent=int((movie.getBytesLoaded()\/movie.getBytesTotal())*100)<br \/>\nthis.loadtext.text=&quot;Loading &quot;+this.percent+&quot;%&quot;;<br \/>\nthis.loadtext.setTextFormat(formtext);<br \/>\nprelBar._xscale=this.percent;<br \/>\n}<br \/>\nif(this.percent==100) {<br \/>\ndelete this.onEnterFrame;<br \/>\nthis.removeMovieClip();<br \/>\nprelBar.removeMovieClip();<br \/>\n}<br \/>\n}<br \/>\n} <\/p>\n<p>\u4ee5\u4e0a\u4ee3\u7801\u90fd\u5728\u4e3b\u573a\u666f\u7b2c\u4e00\u6862\u3002\u5982\u8981\u6b64\u4ee3\u7801\u5de5\u4f5c\u8be5\u5982\u4f55\u8bbe\u7f6e\uff1f\u4e3e\u4e2a\u4f8b\u5b50\uff1a<br \/>\n\u6bd4\u5982\u4f60\u8981load\u4e00\u4e2ajpg(name:mm)\u6216\u8005\u4e00\u4e2aswf(name:gg)<br \/>\n\u5219\u53ef\u4ee5\u5728\u4e3b\u573a\u666f\u4e2d\u521b\u5efa\u4e00\u4e2a\u7a7aMC\uff08instance name:mc)\uff08\u6216\u8005\u76f4\u63a5load\u8fdb\u4e3b\u573a\u666f\uff09\u7136\u540e\u5728\u68621\u4e2d\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<br \/>\n_root.mc.loadhere(0,0,&quot;mm.jpg&quot;,&quot;mm&quot;);\u6216\u8005_root.mc.loadhere(0,0,&quot;gg.swf&quot;,&quot;gg&quot;);<\/p>\n<p>\u4ee5\u540e\u4f60\u82e5\u60f3LOAD jip \u6216\u8005swf\u90fd\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u4e0a\u9762\u7684\u4ee3\u7801\uff0c\u4f60\u8fd8\u53ef\u4ee5\u6539\u53d8\u8fdb\u5ea6\u6761\u7684\u989c\u8272\uff0c\u5927\u5c0f\u7b49\uff0c\u5f88\u65b9\u4fbf\u3002\u9700\u8981\u6307\u51fa\u7684\u662f\uff0c\u5728\u672c\u5730\u65e0\u6cd5\u89c2\u770b\u6548\u679c\u3002\u6709\u7a7a\u95f4\u7684\u670b\u53cb\u53ef\u4ee5\u8bd5\u4e00\u8bd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5168\u90e8AS\u5b8c\u6210\u3002 MovieClip.pr&hellip;  <a href=\"https:\/\/inhaoxu.com\/blog\/?p=466\" class=\"more-link\">more <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[708,390,709,707],"_links":{"self":[{"href":"https:\/\/inhaoxu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/466"}],"collection":[{"href":"https:\/\/inhaoxu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inhaoxu.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inhaoxu.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inhaoxu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=466"}],"version-history":[{"count":0,"href":"https:\/\/inhaoxu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/466\/revisions"}],"wp:attachment":[{"href":"https:\/\/inhaoxu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inhaoxu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inhaoxu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}