Flex child components that don't interfere with mouse events

Gary McGhee - Tuesday, May 19, 2009

I have a bitmap that I want to act as a button, complete with the standard mouse hover cursor (hand).  I also have a label I want overlaid over the bitmap. 

Firstly, there are various posts out there about custom mouse cursors, but it surprisingly hard to find anything on the standard hand pointer that appears when the mouse is over a link. "buttonMode = true" is the answer to that one, but it doesn't work for everything.

Secondly, the label must be in front of the bitmap, but not interefere with the mouse. The answer to this was to make the label a child of the image, and then to set "imgCart.mouseChildren = false". This makes the label ignore mouse events, which fall through to its parent.

Some actionscript in creationComplete that makes the label a child of the image control, then centers its position within the image :

var lbl: Label = lblCartCount;
lbl.parent.removeChild(lbl)
imgCart.addChild(lbl);
lbl.x = (imgCart.width - lbl.width) / 2 - 5
lbl.y = (imgCart.height - lbl.height) / 2

Pure Actionscript HTML Parser (with thanks to John Resig)

Gary McGhee - Thursday, May 14, 2009
I am writing a Flex ecommerce store that needs to work with Mals Ecommerce. I am posting values to Mals to add to the cart, and the result is a HTML 4.0 page of the shopping cart, which I need to extract some information from. Parsing HTML would be much easier if it could be converted to XML for use with Flex's built in XML parser. At first I tried quoting unquoted attributes, but then found unclosed tags and it all seemed too hard, so I went looking for a HTML parser in ActionScript, with no success. Then i remembered that ActionScript is supposed to be a superset of Javascript, and the amount of serious code being written in Javascript these days continues to surprise me. This led to this Javascript HTML Parser whipped up by Javascript guru and JQuery creator John Resig.

With some quick hacking, here is my version.