Step 4. Defining the Triangle Component Properties
It is now time to define officially the component parameters in the Component Definition window. Open the Library panel and find the Triangle Component movie clip you made (it shouldn't be hard, because it should be the only symbol in the Library). Open the Component Definition window by right-clicking (Windows) or Ctrl-clicking (Mac) on the movie clip and choosing "Component Definition ".
In this window, you enter the parameters for your component. The plus and minus at the top are used to add properties or remove properties, respectively. By default, properties are added of type Default, with a value of defaultValue. These come out as Strings. Flash MX allows you to make properties of the following types: Default, Array, Object, List, String, Number, Boolean, Font Name, and Color. There are four columns in this topmost box. The first column, Name, is the text you would like to be shown in the component property inspector. The name may contain spaces, alphanumeric characters, and punctuation. You would enter a descriptive title for the parameter in this space.
The second column, Variable, is the name of the property name you use in your component scripts. This cannot have spaces or punctuation marks, except for the underline character (which may not be the first character). Having both Name and Variable allows you to use a short property name in your script, but to present a more descriptive phrase to help the component user understand what each value represents.
Note: If you specify a Variable but no Name, Flash puts the name of the variable in the property inspector. If you specify a Name but no Variable, you use that Name in your script to refer to the property.
The third column, Value, is the default starting value for the property. The final column is the type of the parameter, selected by choosing from the drop-down list. For our triangle component, add the following properties:
Since we do not yet have a custom User Interface or a Live Preview movie for the component, leave the next two lines, Custom UI and Live Preview, blank. If you want to enter a text description for to help users understand the function of your component, press the Set button on the opposite side (right) of the Description box. In the Description window that appears, select "Description Is Plain Text" and enter the description in the area provided. The other option is to create a formatted description in the Reference panel ("Description is a Reference Panel Item"). See the Flash documentation or Flash MX Developer Site for information on creating a reference panel description for the component.
Choose an icon for the component to accompany its name by pressing and holding the icon located directly beneath the Description label. In the next step, we will show you how to define a custom icon.
Beneath this area are two options: whether or not to lock parameters in instances (meaning that a user can or cannot add parameters when the component has been put on the stage), and whether or not to display the component in the Components panel. Note: If you check the "Display in Components panel", the component will not automatically be added to the Components Panel. We will talk about how to do this when we discuss deploying the component. Choose OK to continue.
|» Level Intermediate|
Rating: 8 Votes: 55
|Jonathan Kaye, PhD, is the President and CTO of Amethyst Research LLC, an award-winning interactive design and engineering firm specializing in the creation of online device simulations. He and David Castillo are the authors of "Flash for Interactive Simulation: How to Construct and Use Device Simulations", to be published by Delmar Thomson Learning in November, 2002 (the accompanying web site will be www.FlashSim.com).|
|Download the files used in this tutorial.|
|Download (0 kb)|
|More help? Search our boards for quick answers!|