Solved

Flash Pro 8: LoadVars and onHTTPStatus help!

Posted on 2006-06-21
9
377 Views
Last Modified: 2008-01-09
Hello experts. I can't seem to get onHTTPStatus to do... well... anything!

Here's the code I'm playing with. Even the examples of onHTTPStatus wont work out of the box.

var myLoadVar = new LoadVars();

            myLoadVar.onHTTPStatus = function(httpStatus:Number)
                                {
                                        _root.test1 = this.httpStatus + " : " + Number;
            }
            
            myLoadVar.onData = function(dat)
            {
                      _root.test1 = dat + " : " + httpStatus + " : " + Number;
            }

myLoadVar.onLoad("http://www.yahoo.com");

All I want to do is return the status codes and be able to view them.

Thank you very much.

Best regards,

Dr34m3r
0
Comment
Question by:dr34m3rs
  • 6
  • 3
9 Comments
 
LVL 37

Accepted Solution

by:
CyanBlue earned 500 total points
ID: 16956635
The last line should be load() not onLoad()...

myLoadVar.load("http://www.yahoo.com");

Please check the Flash Help page on LoadVars.onHTTPStatus for complete example code...

CyanBlue
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 16956837
If I use a domain that is alive like:

                var myLoadVar = new LoadVars();
            
            myLoadVar.onHTTPStatus = function(httpStatus:Number) {
                       _root.test1 = this.httpStatus + " : " + Number;
            }
            
            myLoadVar.onData = function(dat)
            {
                  _root.test1 = dat + " : " + httpStatus + " : " + Number;
            }
            
            myLoadVar.load("http://www.yahoo.com");

My output is "<HTML><HEAD>";

Which is odd because I added " : " to both dynamic text instances.

If I use a domain that's down like:

var myLoadVar = new LoadVars();
            
            myLoadVar.onHTTPStatus = function(httpStatus:Number) {
                       _root.test1 = this.httpStatus + " : " + Number;
            }
            
            myLoadVar.onData = function(dat)
            {
                  _root.test1 = dat + " : " + httpStatus + " : " + Number;
            }
            
            myLoadVar.load("http://www.testw3w3.com");

I get "undefined : undefined : [type Function]" as my output. : - /


The examples don't help me as they don't actually work! No one seems to use it either... which makes me think it's broken / bugged??

Help would be much appreciated I'd love to be able to use it!!!!

0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 16956846
onHTTPError may be useful in this instance, as anything that isn't an error will be alive.

I'll look into it.
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 1

Author Comment

by:dr34m3rs
ID: 16957019
onHTTPError looks to be more for event handleing than what I'm doing.

onHTTPStatus would work better.
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 16957033
Well that was easy!

I had to change

var myLoadVar = new LoadVars();

To

var myLoadVar:LoadVars = new LoadVars(); Can we say redundant? Lol...

Thanks!!
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16957044
I thought that it is not mandatory, but I guess it is...  Good find...  ;)

CyanBlue
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 16957129
Oddly, I'm not sure what it was now!! : - /

I took the extra LoadVars out and it still worked...  I must have changed something inadvertently without realizing that it worked... or... there's a ghost in my machine!

In either case, here's my resulting test code (working this time):

Thanks again (and stay blue!)!!  =D

Here's the beta code:


// Coded by Dr34m3r with very special thanks to aneeshchopra, blue-genie and CyanBlue from Experts-Exchange.Com

_root._domain = "http://test.com";

checkDomainUp = function (_d)
{
            var myLoadVar = new LoadVars();
            
            myLoadVar.onHTTPStatus = function(httpStatus)
            {
                  if(httpStatus > 0 &&  httpStatus < 400)
                  {
                    _root._result = _d + " is alive with code " + httpStatus;
                  }
                  else
                  {
                        _root._result = _d + " is down with code: " + httpStatus;
                  }
            }
            
            myLoadVar.load(_d);
}

_root.checkDomainUp(_root._domain);
0
 
LVL 1

Author Comment

by:dr34m3rs
ID: 16957135
Oh and one more thing that's cool about this is, it seems to have a timeout of only 5 seconds, which saves me the trouble of trying to add a timeout code to it myself. =D
0
 
LVL 37

Expert Comment

by:CyanBlue
ID: 16958774
That sounds cool...  Glad to hear that you've got all you need...  ;)

CyanBlue
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

772 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