on new ( me , netaddress, callbackobj, completionmsg) mycallbackobj = callbackobj mycompletionmsg = completionmsg mynetid = preloadnetthing (netaddress) atimerobj = timeout ( me . string ). new ( 100 , # timer_checkprogress, me ) end
on timer_checkprogress ( me , atimer) finished = netdone (mynetid) if finished then errornotification = "" errornum = neterror (mynetid) if integerp (errornum) then if errornum then errornotification = me ._geterror(errornum) end if end if atimer. forget () call (mycompletionmsg, mycallbackobj, errornotification) else put "still downloading" end if end
on _geterror ( me , errorcode) case errorcode of "ok" , "" , 0: return empty 4: errormsg =( "bad moa class. the required xtras are missing. " ) 5: errormsg =( "the required xtras are improperly installed or not installed at all." ) 6: errormsg =( "bad url or the required xtras are improperly installed. " ) 20: errormsg =( "internal error. the browser detected a network or internal error." ) 4146: errormsg =( "connection could not be established with the remote host." ) 4149: errormsg =( "data supplied by the server was in an unexpected format." ) 4150: errormsg =( "unexpected early closing of connection." ) 4154: errormsg =( "operation could not be completed due to timeout." ) 4155: errormsg =( "not enough memory available to complete the transaction." ) 4156: errormsg =( "protocol reply to request indicates an error in the reply." ) 4157: errormsg =( "transaction failed to be authenticated." ) 4159: errormsg =( "invalid url." ) 4164: errormsg =( "could not create a socket." ) 4165: errormsg =( "requested object could not be found (url may be incorrect)." ) 4166: errormsg =( "generic proxy failure." ) 4167: errormsg =( "transfer was intentionally interrupted by client." ) 4242: errormsg =( "download stopped by netabort(url)." ) 4836: errormsg =( "download stopped for an unknown reason, possibly a network error, or the download was abandoned." ) otherwise errormsg =( "unknown error code" ) end case return errormsg end
要想看到具体返回了什么参数,可以像下面这样修改“preloaderinterface”行为:
on beginsprite me clearcache () urltoload = "http://www.lingoworkshop.com/tutorials/preloader/main.dcr" script ( "preloader" ). new (urltoload, me , # mhandlepreloadcompletion) end
on mhandlepreloadcompletion ( me , errormsg) if errormsg <> empty then alert "network error!" & return & errormsg else alert "all done" end