10.1. Dock Icons
Mac OS X has a dock that is mounted either at the right side, left side, or bottom of the screen. The dock contains shortcuts to open installed applications and also shows currently running applications. Chapter 6 demonstrated how to create custom icons for the installer. This icon would be the one shown in the dock when an application launches. AIR also gives us the ability to change the dock icon while the application is running. This can be very useful to display information to the user. Changing the icon is a simple process and simply requires the creation of a flash.display.BitmapData object. This can be created from an existing image displayed within the application or can be created from an embedded image class.
To get started, please create a new AIR project named Chapter10_Dock, which will create a new file named Chapter10_Dock.mxml. You will also need an image file to use as the dock icon. The source code that is part of this book has four PNG files representing four different-sized icons that I created. The image sizes are 16 × 16, 32 × 32, 48 × 48, and 128 × 128. As you will see shortly, the dock icon accepts an array of images of various sizes and then uses the best image to fit the situation; you can get away with using just one mid-sized image, which will be scaled accordingly.
We'll now proceed to the source code for adding a dock icon. Enter the code from Listing 10-1 into the newly created Chapter10_Dock.mxml file. If you only have one icon image ...
Get Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.