| By Colin Moock | Article Rating: |
|
| June 15, 2005 11:00 AM EDT | Reads: |
21,283 |
In Part One of this two-part article ("Skinning the V2 ProgressBar component " MXDJ vol 3 issue 4) we did what we set out to do, but I just can't bear to leave the skinning-a-Button issue unresolved.
The warning at the beginning of last month's article pointed out that the Button component is surprisingly difficult to skin because its skin is made up of code, not graphics. As a last exercise, then, let's take a quick look at an alternative approach: skinning SimpleButton instead of Button.
The SimpleButton class is the superclass of Button, and is accordingly less complex. Specifically, SimpleButton instances cannot be resized and do not have text labels - which makes them easy to skin. Follow these steps to skin a SimpleButton instance:
- Create a new Flash document (.fla file).
- Drag a Button instance to the stage and then delete it. This adds the Button component to the document Library.
- Create four movie clips, named up, over, down, and icon, with Linkage Identifiers set to "up", "over", "down", and "icon", respectively.
- In the up movie clip, create a graphic that represents the button in an idle state.
- In the over movie clip, create a graphic that represents the button when the mouse pointer is above it.
- In the down movie clip, create a graphic that represents the button when it is pressed.
- In the icon movie clip, create a graphic that will appear in the middle of the button in all states.
- Select Frame 1, Layer 1.
- Add the following code to the Actions panel:
import mx.controls.*;
var initObj = {falseUpSkin:"up",
falseDownSkin:"down",
falseOverSkin:"over"};
initObj.falseUpIcon = "icon";
initObj.falseDownIcon = "icon";
initObj.falseOverIcon = "icon";
initObj.trueUpIcon = "icon";
initObj.trueDownIcon = "icon";
initObj.trueOverIcon = "icon";
// Cast the object returned by createClassObject() to SimpleButton.
var sButton:SimpleButton = SimpleButton(
this.createClassObject(SimpleButton,
"sButtonInstance",
0,
initObj));
sButton.move(250, 200); - To export the movie, choose Control > Test Movie.
The SimpleButton class is not the only alternative to the Button component. The CustomButton class can also be skinned with graphical movie clips. CustomButton offers the additional features of resizability and a text label. Note, however, that a CustomButton instance can be resized along one axis only - either horizontally or vertically. Accordingly, the CustomButton skin is structured much like the ProgressBar skin; it has two end caps for the edges of the button and a middle section that is stretched between the caps. You can use the SimpleButton skinning technique described above to skin a CustomButton instance. Of course, you'll have to use the CustomButton skin properties instead of the SimpleButton skin properties. For reference, here is a list of CustomButton's skin properties:
- falseUpSkinL
- falseUpSkinM
- falseUpSkinR
- falseDownSkinL
- falseDownSkinM
- falseDownSkinR
- falseOverSkinL
- falseOverSkinM
- falseOverSkinR
- trueUpSkinL
- trueUpSkinM
- trueUpSkinR
- trueDownSkinL
- trueDownSkinM
- trueDownSkinR
- trueOverSkinL
- trueOverSkinM
- trueOverSkinR
- falseDisabledSkinL
- falseDisabledSkinM
- falseDisabledSkinR
- trueDisabledSkinL
- trueDisabledSkinM
- trueDisabledSkinR
Note, however, that rather than relying on the above list of CustomButton skin properties you should always consult the actual source code for the CustomButton class to verify which skin properties it supports. Different versions of the class may support different properties. The source code also contains a brief description for each skin element. The source file for CustomButton is located here:
- Windows: \Program Files\Macromedia\Flash MX 2004\[LANGUAGE_CODE]\First Run\Classes\mx\controls\CustomButton.as
- Macintosh: HD/Applications/Macromedia Flash MX 2004/First Run/Classes/mx/controls/CustomButton.as
Published June 15, 2005 Reads 21,283
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
About Colin Moock
Colin Moock is an independent web guru with a passion for networked
creativity and expression. He is author of the world-renowned guides to
Flash programming, "ActionScript for Flash MX: The Definitive Guide" (O'Reilly
& Associates, 2003, 2001) and "Essential ActionScript 2.0" (O'Reilly &
Associates, 2004). A web professional since 1995, Moock runs one of the web's most venerable Flash developer sites, www.moock.org. He spends most of his
time pursuing his cardinal interest, multiuser application development, and
working on Unity, moock.org's complete commercial framework for creating and
deploying multiuser applications for Macromedia Flash.
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Java Kicks Ruby on Rails in the Butt
- Ulitzer’s Amazing First 30 Days in Public Beta
- "Government IT Expo" to Highlight Cloud Computing and SOA
- Will Ulitzer Dominate News Content on The Web? -Gartner
- Clear Toolkit 4: The Road Map
- Creating Adobe AIR Native Menu with Flash CS4
- Menu Interaction in Adobe AIR
- The Darker Sides Of Cloud Computing: Security and Availability
- Ulitzer vs. Ning - a Quick Review
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Creating PDF Documents from Flex Applications
- Java Kicks Ruby on Rails in the Butt
- WebORB Launched for Flex, Flash, AJAX and Silverlight
- Adobe Takes LiveCycle into the Cloud
- Ulitzer’s Amazing First 30 Days in Public Beta
- Adobe Creates a Sandbox in the Sky
- AJAX and RIA Market Is Heating Up: Sun CEO
- "Government IT Expo" to Highlight Cloud Computing and SOA
- Will Ulitzer Dominate News Content on The Web? -Gartner
- Cover Story: How to Increase the Frame Rates of Your Flash Movies
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Your First Adobe Flex Application with a ColdFusion Backend
- Adobe Flex 2: Advanced DataGrid
- Adobe/Macromedia - Microsoft, Look Out!
- i-Technology Blog: Death-Knell For "Rich Media? Hardly!
- Adobe Flex Interface Customization - Themes, Styles, Skins
- Personal Branding Checklist
- How To Create a Photo Slide Show ...
- "Real-World Flex" by Adobe's Christophe Coenraets









































