Solved

Flash: loadVars() need timeout function.

Posted on 2006-06-20
11
752 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
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.

728 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