Flex 3: Firefox Beta 3 returns 0 for HTTP status codes

Flex 3: Firefox Beta 3 returns 0 for HTTP status codes

John C. Bland II

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”:http://www.sargeway.com/blog. 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:
bq. “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”:http://livedocs.adobe.com/flex/3/langref/flash/events/HTTPStatusEvent.html

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! ;-)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值