Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-11-2007, 02:04 PM
Junior Member
 
Join Date: Jan 2007
Posts: 13
Default inet preloader freeze

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!
Reply With Quote
  #2 (permalink)  
Old 01-11-2007, 02:34 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:inet preloader freeze

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
Reply With Quote
  #3 (permalink)  
Old 01-11-2007, 05:21 PM
Junior Member
 
Join Date: Jan 2007
Posts: 13
Default Re:inet preloader freeze

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.

Reply With Quote
  #4 (permalink)  
Old 01-11-2007, 06:24 PM
Junior Member
 
Join Date: Jan 2007
Posts: 13
Default Re:inet preloader freeze

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
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:00 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.