Solved

Flash Pro 8: LoadVars and onHTTPStatus help!

Posted on 2006-06-21
9
371 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
onHTTPError looks to be more for event handleing than what I'm doing.

onHTTPStatus would work better.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Author Comment

by:dr34m3rs
Comment Utility
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
Comment Utility
I thought that it is not mandatory, but I guess it is...  Good find...  ;)

CyanBlue
0
 
LVL 1

Author Comment

by:dr34m3rs
Comment Utility
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
Comment Utility
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
Comment Utility
That sounds cool...  Glad to hear that you've got all you need...  ;)

CyanBlue
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

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…
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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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

11 Experts available now in Live!

Get 1:1 Help Now