Solved

Flash: loadVars() need timeout function.

Posted on 2006-06-20
11
746 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
Comment Utility
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
Comment Utility
Hi, why don't you use the onHTTPStatus method to check?
0
 
LVL 1

Author Comment

by:dr34m3rs
Comment Utility
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
 
LVL 39

Expert Comment

by:blue-genie
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 37

Expert Comment

by:CyanBlue
Comment Utility
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
Comment Utility
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
Comment Utility
Cool...  Love the blue!!!  :)

CyanBlue
0
 
LVL 39

Expert Comment

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

Expert Comment

by:CyanBlue
Comment Utility
Very true...  ;)
0
 
LVL 1

Author Comment

by:dr34m3rs
Comment Utility
<3
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now