on beginsprite ( me ) if the runmode = "author" then clearcache () script ( "preloader" ). new (myurl, me , # mhandlepreloadcompletion, # mshowprogess) end
on exitframe ( me ) go to the frame end
-- 来自接口对象(例如进度条)的消息 on mregisterwidget ( me , obj, id) if id = # progressbar then myprogressbarobj = obj end
-- 来自“preloader”对象的消息 on mhandlepreloadcompletion ( me , errormsg) if errormsg <> empty then alert "network error!" & return & errormsg else alert "all done" end
on mshowprogess ( me , statuslist) if myprogressbarobj. ilk = # instance then if statuslist. state = "inprogress" then myprogressbarobj.mshowprogress(statuslist.fractiondone) else myprogressbarobj.mshowworking() end if end
-- 构造行为 on getpropertydescriptionlist ( me ) pdlist = [:] pdlist[ # myurl] = [ # comment: "url" , # format: #string , # default: "http://www.lingoworkshop.com/tutorials/preloader/main.dcr" ] return pdlist end