Solved

Flash Pro 8: LoadVars and onHTTPStatus help!

Posted on 2006-06-21
9
379 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

789 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