Tuesday, January 16, 2007

nullpointerexception in flex style compiling

So far my experience with flex builder's compiler and debugger has been amazing.
However I ran into my first encounter with bad error reporting today.

I would get java.exception.NullPointerException on the tag <mx:Style source="somestyle.css"/>. Hrm. Had to go through commenting out the stylesheet until it compiled to figure out that the swf I generated from an .fla where I didn't have fonts wouldn't coerce the system fonts into the expected names, so trying to access them in that swf generated the exception.
Annoying that the part of the css that caused the error wasn't pointed to - the compiler I guess calls some other java css compiler and can't bubble the details into its context.

Oh well, still a pretty easy thing to fix, but I felt like I was back in javascript or php land, commenting out partial pieces of code to find the culprit breaking the build =)

Monday, January 8, 2007

Progress Event in Flex's URLStream

The low down is that the progress event does not work like I wanted it to. In case anyone else is attempting to use it and running into problems, I feel for you.

I have a .net aspx page which stores the Response stream in the application state and just idles, so that other page activations can write to it when needed. I keep track of client ID's and all is good: I can send the right stuff to the right clients.

However, I needed to set up polling on URLStream.bytesAvailable because ProgressEvent wouldn't fire if only a few bytes had been received. I also have to send at least 300 bytes to get Response.Flush() to actually flush! Kind of annoying. I try to avoid setInterval like the plague. Another odd thing, before any bytesAvailable is shown, I have to send about 2000 bytes. Then I can detect changes within 3-400 bytes as they come in, even if separated by 10 seconds or 10 minutes.

Now I have a framework accomplishing server push where clients can interact very quickly and be aware of eachother's actions immediately.

Say a user posts a reply in a forum you're currently looking at. Well, his page activation to save his reply will trigger a server-side event listener you established on that forum, causing you to get the updated data BEFORE it's even written to the database. Your view updates the forum live as if it were some kind of chat application. No need to refresh constantly while at work and tabbing back into that forum you're interested in, just leave it up and see the replies already there when you tab back in.

This is a HUGE step forward imo. All this talk about web 2.0 and I'm excited to be part of it.. and to be doing it right; not with some polling ajax hack.

Flex rocks.

I haven't been posting a lot of my work lately because I got a talk from the boss about keeping it under wraps. So I likely won't be posting code here anymore.