I’ve made my first contribution to the flexlib project: the IconLoader component.
The IconLoader control has an interface similar to <mx:Image>, but instead of displaying a PNG, JPEG or other bitmap image, it displays an icon. The control understands the Windows .ico and Mac OS .icns file formats. Icon files usually contain images at various sizes. The IconLoader control will choose the most appropriate size given the size of the control itself. E.g. if the control is explicitly sized to 40 pixels wide and 42 pixels high, and the source icon file contains a 32×32 icon, that icon will be used. Like with <mx:Image>, IconLoader has a scaleContents property. When this is set to true, the icon is scaled to fill the control’s bounds.
The source property can either be set to a string or an embedded object. Strings are interpreted as URLs, and the icon file is retrieved and parsed. It’s also possible to use the @Embed directive to set the source property to an embedded byte array.
A quick note on the latter usage of the source property. Any arbitrary data file can be embedded in a flex app by setting the mime-type property of the @Embed directive to application/octet-stream. The embedded class extends ByteArray, so it’s trivial to examine the contents of the file. Thanks to Doug McCune for turning me on to this technique.