What a weird issue to run into but I did.

So, yesterday I was tasked with building a charting app (simple 1 chart based on XML with a refresh interval). No problem…jumped in Flex Builder and banged it out in roughly 20 minutes (not bragging; will explain the reference in a few). The app worked perfectly fine.

Today I was tasked with integrating it into the actual page and putting up a test version to look at. So I did, showed Dave M. (he assigned it to me) but he was busy so I showed my manager, and it didn’t work!!! Huh?

First Error
My manager hit an RSL problem. The issue was with the “mime type not being registered”:http://kb.adobe.com/selfservice/viewContent.do?externalId=kb402864 in Apache. Easy one to get beyond. I nix’ed the use of RSL for now, until Apache on this server gets updated, and moved one.

Second Error
The code uses a URLLoader to load the XML. I added a listener for HTTPStatusEvent.HTTP_STATUS. 403 and 401 are there for authentication purposes and 200 is the only other I coded. Everything works great. If I get a 200 the timer is stopped then started again. I also have an Event.COMPLETE to “parse” the data and throw it in my chart (which charting+xml is saweet!!!). Again…everything works great. I sent it to my manager…BROKEN! Ahh…only in Firefox though. Huh? How’s that? This is Flash for Christ’s sake!!

I remove my setInterval and replace it with a Timer. That doesn’t work. I tried numerous other fixes and none of those worked. Then I added a double click listener to the chart and had it call loadData which actually worked. So I knew the networking portion was fine. Why in the world is my switch statement not making it to case 200:?

To find out I threw in an Alert.show(event.status) to see what code was coming back. It was 0!!!! HOW? HUH? WHAT?

Last year I learned a new acronym from Sarge. We were working on something and the issue I was having was a result of RTFM. RTFM (to me) reads “Read The Freaking Manual” (substitute your own F* word at your leisure). 🙂

That was the problem…RTFM:

HTTPStatusEvent objects are always sent before error or completion events. An HTTPStatusEvent object does not necessarily indicate an error condition; it simply reflects the HTTP status code (if any) that is provided by the networking stack. Some Flash Player environments may be unable to detect HTTP status codes; a status code of 0 is always reported in these cases.
-Source Adobe LiveDocs – HTTPStatusEvent

Hopefully this helps someone. I basically moved my case 200: code to my Event.COMPLETE handler and everything is good to go. The 403 and 401 blocks aren’t too important because you have to login before getting to the swf anyway so I didn’t worry about moving them.

All is well…everything works and almost 2 hours of debugging on a 20 minute app RTFM allows me to check it in and be done with it! 😉

Updated: 6/28/11 – Replaced templating language with HTML equivalents.