Solved

Flash Pro 8: LoadVars and onHTTPStatus help!

Posted on 2006-06-21
9
380 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
[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
  • 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
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!

 
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

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…
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 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.

749 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