Solved

Flash: loadVars() need timeout function.

Posted on 2006-06-20
11
750 Views
Last Modified: 2012-05-05
The following is to check if a domain is up or not.

I need a timeout of say 5 seconds. I am checking a lot of domains at once and don't want to have to wait if a domain is responding slow, also I don't even need to load any variables since I wont use them.

Is there a way to undefine the variables that are loaded or just skip the loading of them alltogether, just see if the domain is alive and quit/timeout?

checkDomainUp = function (stuff)
{
      var myLoadVar = new LoadVars();
      myLoadVar.onData = function(dat)
      {
            if (dat != undefined)
            {
                  //alive code
            }
            else
            {
                                               //down code
            }
      };
      myLoadVar.load(stuff);
};

Also, does anyone know if you can thread loadvars...  have more than one of them running at the same time??

Thank you very much.

Best regards,

Dr34m3r
0
Comment
Question by:dr34m3rs
  • 4
  • 4
  • 3
11 Comments
 
LVL 37

Assisted Solution

by:CyanBlue
CyanBlue earned 250 total points
ID: 16941714
Howdy...

Here is a pseudo code for you by using the setInterval()/clearInterval() function...
You might need to tweak the code abit but you get the idea...
Mind you that you cannot really stop the return data from the server even if you delete the myLoadVars instance...  Flash will still receive the data...
Also, you can have more than one running at the same time as long as you have different instance names(myLoadVar, iv0001)...

var myLoadVar = new LoadVars();
iv0001 = setInterval("checkIdle", 1000, myLoadVar);
myLoadVar.iv = iv0001;
myLoadVar.onData = function(dat)
{
      if (dat != undefined)
      {
            //alive code
      }
      else
      {
            //down code
      }
};
myLoadVar.load(stuff);

function checkIdle(_arg)
{
      if (counter0001 < 5)
      {
            counter0001 += 1;
      }
      else
      {
            clearInterval(iv0001);
            delete _arg;
      }
}

CyanBlue
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 250 total points
ID: 16942931
Hi, why don't you use the onHTTPStatus method to check?
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 16943071
Wow, great idea didn't know it existed!

So basically onHTTPStatus returns an HTTP response code?

Can you give an example? Can't find any reasonable explanations... also does it have a timeout? If so what is the default?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 39

Expert Comment

by:blue-genie
ID: 16943093
have a look in the help file, it's there with all the codes.
and i'm sure there's an example there as well.
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 16943097
CyanBlue, do you know how much data loadvars can handle? I don't wanna be downloading megs of data by mistake =D heh....

Also thanks for the timer, I'll check it out when I wake up.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16947082
Thanks, blue-genie...
onHTTPStatus...  Never knew what that was all about...  That's what happens if you live in FMXville...  :D

dr34m3rs...  
As far as I know of, you get all that is provided via HTTP pipe...  There is no limit Flash will try to download the data...  Of course, that might eventually crash the Flash if there is more than Flash can handle...
What are you trying to download???

CyanBlue
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 16947166
Hey, I'm not trying to download anything actually. All I want to do is know if the domain is up or not, and I think the httpstatus will work great for that as it only checks to see what the HTTP code is. Very handy for what I'm doing. Along with your timer code I should be good to go!!

I'm going to split up the points here as all my questions were answered.

To be fair 250 for each, the onHTTPStatus was a great find, and the counter and answer for how much flash can handle via loadvars was uber too!

Thanks alot for your help CyanBlue and blue-genie (stay blue!! cuz being blue is cooool....)

Dr34m3r
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16947346
Cool...  Love the blue!!!  :)

CyanBlue
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 16948847
blue rocks!!! and hey, i like FMXville -nice and comfortable with no surprises.
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16950261
Very true...  ;)
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 16950440
<3
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question