Solved

Flash Pro 8: LoadVars and onHTTPStatus help!

Posted on 2006-06-21
9
374 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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 the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

947 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

20 Experts available now in Live!

Get 1:1 Help Now