The AS3 components in CS4 allow for visually showing that the component is focused, using a code generated or libary asset sprite as the focusRect. This can be changed using the focusRect property or through the #setStyle method inherited by all UIComponent’s. The outlying size of the focusRect can also be altered by setting the focusRectPadding style, which designates the number of pixels outside the size of the component that the focusRect sits. Unfortunately, if you are using TextInput, and likely TextArea, setting this padding to 0 results in hiding the focusRect behind the component skin (the grey outline for the TextInput). This is a result of the fact that the UIComponent#drawFocus sets the childIndex of the focusRect sprite to 0, essentially placing it behind the TextInput border. I wanted to create a subclass of TextInput for which I didn’t need to reset several defaults every time I used it, so I created the class below, which also fixes the 0 padding focusRect issue.
Read More »
A quick note regarding something I’ve been meaning to post a short note about for a while, for those that might be running into problems resulting from shapes drawn in flash with an outline. I ran into this recently again, so I thought I’d post for any concerned parties out there.
Regardless of whether or not a shape, such as a rectangle, is drawn in Flash with a hairline border line, or a borderline of 1, the result on an unscaled shape is essentially the same. The crisp outline of the shape is drawn with a pixel width of 1. The downside of this occurs when trying to create pixel perfect UI’s, and especially those using shapes with a scalenine grid assigned to them.
Read More »
April 13, 2009 – 10:45 am
Just a quick note for those possibly searching for ComboBox AS3 and “Cannot access a property or method of a null object reference.” When using the AS3 ComboBox, the above error will be thrown when the ComboBox loses focus, if the ComboBox is in its open state and it has lost reference to the stage. In other words, if you have a UI pane that contains the ComboBox, and you are removing the pane, make sure to first call #close() on all instances of the ComboBox, then remove the container from its parent container. (This can be replicated by clicking open the ComboBox, then clicking on the stage.) Unfortunately, the isOpen property for the ComboBox is not publicly accessible, but the #close() method is a NOOP if it is already closed, so just making sure to close it is no big deal. I ran into this error because I was listening for a stage focus event which triggered the immediate removal of the container pane in question, but I didn’t find any relevant references in a quick web search, so I thought I’d make a quick post with the solution.