|
|||
|
Hi all!
I want to download 800kb data (png image) from internet with Inet. i added callback function for preloader, and resolve the http file size. But the download starts the flash player says "Flash player running to slowly bla bla". When download finished flash player come back, and my preloader jump 0 to 100%. The code : function on_geturl(type, msg) { if (fstatus == 200) { status = status+"\n"+fstatus+" (OK) :"+filesize+"/"+msg; status.scroll = status.maxscroll; percent = (msg/filesize)*100; loader_mc.loaderbar._width = percent*2; } else { status = status+"\n"+fstatus+" [ERROR]"; return false; } if (filesize == msg) { godownload = true; } if (!SWFKit.Global.processMsg()) return false; return true; } function downloadFiles(name, ver, loc, desc) { if (srvname[0]) { aktivsrv = srvname[0]; var inet = new Inet; inet.setEventHandler("onGetUrl", on_geturl); fstatus = inet.getHttpFileStatus("http://"+aktivsrv+"/someplace/"+loc); filesize = inet.getHttpFileSize("http://"+aktivsrv+"/someplace/"+loc); if (loc) { inet.getUrl("http://"+aktivsrv+"/someplace/"+loc, loc); } } else { //no server .. error } } and end of the script called downloadFiles("map", "1.0", "map/map.png", "This is the map file"); Can anyone help me? Thanks! |
|
|||
|
We recommend that you write the file downloading code in ffish script and call it in action script asynchrously. For example, put the code in the "download" script, and call it in action script in the following way:
fscommand("ffish_asynrun", "download"); please try the "progress" sample: http://www.swfkit.com/forum/thread_1_1669.html |
|
|||
|
I tryed that to SWFkit add this code on
Init section : Application.registerASMethods("sendToAs"); return true; "download" section : //download var location = FlashPlayer.getVariable("_level0.thisLocation"); var server = FlashPlayer.getVariable("_level0.thisServer"); function on_geturl(type, msg) { sendToAs(type, msg); if (!processMsg()) return; } var inet = new Inet; inet.setEventHandler("onGetUrl", on_geturl); filesize = inet.getHttpFileSize("http://"+server+"/somefolder/"+location); inet.getUrl("http://"+server+"/somefolder/"+location, location); In the AS : function ongeturl(type, msg) { status = status+"\n"+fstatus+" (OK) :"+filesize+"/"+msg; status.scroll = status.maxscroll; percent = (msg/filesize)*100; loader_mc.loaderbar._width = percent*2; if (filesize == msg) { godownload = true; } } _root.thisLocation = "map/map.png"; _root.thisServer = "www.thesrvname.net"; ExternalInterface.addCallback("sendToAs", null, ongeturl); fscommand("ffish_asynrun", "download"); But flash player stopped a moment, map.png downloaded to folder, and flash player running again. I have tryed many combination of scripts but doesnt work. |
|
|||
|
weeeeelaaaa!
![]() I changed the inet.sethandler to : inet.onGetUrl = on_geturl; And the filesize go back to actionscript with setVariable before call inet.geturl.... the AS can count procent works fine! thanx for help |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|