Monday, May 19, 2008

Odd behavior with E4X filtering in AS3

This one drove me nuts today and so I thought I'd better blog it. I was trying to create a function that to filter an xml file using E4X and locate a node with a specific "photoid" attribute:

First I tried to get retrieve the node with the correct id by filtering:

var myList:XMLList = pdXML..photo.(@photoid=="123");

but, it appears that unless the XMLList has more than one item it won't trace anything out when you do this:

trace(myList.toString()); //shows nothing
trace(myList); //also shows nothing


...even though the list clearly has one item in it:

trace(myList.length()); //returns 1

The only way that it will show the node attribute value is when you refer specifically to the attribute in the trace statement like this:

trace(myList.@photoid); // shows "123"

If the xmlList has more than one node it traces fine using toString(). But the thing that JUST occurred to me is that I SHOULD have used toXMLString()-- which (as I just correctly tested) traces the single node correctly. Even so, the xmlList should trace properly even without using the toString() or toXMLString() methods -- like this: trace(myList);

In any event, I'm not sure if this is a bug or a feature but it sure was a frustrating way to spend an afternoon...

Friday, May 16, 2008

Tutorials for skinning Flex components

Here is a blog posting that points to a number of tutorials on how to skin Flex components. I'm not ready to review them now but they will probably come in handy later ;-)

Click Here >

Wednesday, May 14, 2008

Bandwidth and debugging tool

Here is a GREAT tool for testing and debugging:

http://www.charlesproxy.com/

It lets you throttle your bandwidth to test how your page(or flash) works for different users -- plus it allows you to monitor the download times of various objects and the backend communication between flash and your server. VERY useful!

Monday, May 12, 2008

Playing with AS3 Drawing

I've been going through Colin Moocks' AS3 book and trying out some of the examples (along with getting distracted by trying related things). In this piece I tried to create a dynamic randomized drawing window. The colors are pulled randmly from an array, and the app randomly draws 3-9 lines to form an object and also randomly selects the alpha prop. After 6 objects are drawn it deletes the lowest one in the display list. People have been doing this kind of thing for a long time but this was fun to do with AS3:



Saturday, May 3, 2008

Testing regular expressions in flash

Awesome way to test regular expressions:

http://gskinner.com/RegExr/