Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the users internet connection speed...

Status
Not open for further replies.

raznov

Programmer
Apr 8, 2002
110
US
I'm trying to download the tutorial zip listed under FAQ, but the link doesn't work, and the actual html page link is broken too.

I found this page because I was looking for help on determining the users internet connection speed. I was thinking if I could dynamically let them know how long it will take for a movie to load in based on their connetcion. The movie I am working with is quite large and will all load in advance. So, on a 56k modem it may take up to five minutes.

Other links for the tutuorial or other suggestions are helpful.

Kim
 
Here's some code that does what you want, put it in the first 3 frames of your movie (or a separate scene) - the output should be displayed in a dynamic text box with variable name "remain"

Frame 1

//standard preloader "is whole thing loaded?"
//
bytesLoaded = _root.getBytesLoaded();
bytesTotal = _root.getBytesTotal();
//
//initialise timer
//
startTime = getTimer();
//
if (bytesLoaded>=bytesTotal) {
//start main movie
gotoAndPlay(4);
//or nextScene() etc.
}

Frame 2

Empty...

Frame 3

//recheck amount of movie loaded
//
bytesLoaded = _root.getBytesLoaded();
//
//get percentage loaded
//
percentLoaded = Math.round((bytesLoaded/bytesTotal)*100);
//
//check how much time has passed, calculate total time then subtract one from other to get remaining time
//
elapsedTime = getTimer()-startTime;
targetTime = (elapsedTime/percentLoaded)*100;
time = Math.round((targetTime-elapsedTime)/1000);
//
//format the time into minutes and seconds, lose this section if you just want seconds
//
minutes = Math.floor(time/60);
seconds = time%60;
if (seconds<10) {
seconds = &quot;0&quot;+seconds;
}
//format text output
remain = minutes+&quot;:&quot;+seconds;
//loop
if (percentLoaded<100) {
gotoAndPlay(2);
}
Slainte

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top