![MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Скачать руководство пользователя страница 30](http://html1.mh-extra.com/html/macromedia/flex-developing-components-and-themes/flex-developing-components-and-themes_manual_3388115030.webp)
30
Chapter 2: Creating Basic Components in Flash MX 2004
23.
Copy the SWC file that you created (BlueButton.swc) to the same directory as the MXML file.
This should not be the same directory into which you saved the ActionScript and FLA file. This
directory must be in the web application’s directory structure so that Flex can compile a SWF
from the MXML file.
24.
Request the MXML file in your browser or a stand-alone Flash Player. The blue button should
appear.
Working with component properties
Most components have instance properties that the Flex author can set while adding the
component to the application. To make this possible, you add properties to the class definition.
You can set all component properties as properties in MXML and in ActionScript, unless they are
explicitly marked private.
You can expose component properties by doing the following:
•
Creating an instance variable
•
Defining getters and setters
These methods are described in the following sections.
Creating an instance variable
Creating instance variables is simple. In the component’s ActionScript class file, you declare a
variable:
var myName:String;
If the variable declaration does not specify a default value, your code must either take into
account that
myName
might be
undefined
, or the user could encounter unexpected results.
In MXML, you set that property using a tag property:
<MyComponent myName="Ted" />
As a result, you should define a default value for most regular properties, as the following example
shows:
var myName:String = "Fred";
You can use the Inspectable keyword to set the default value of a property and to limit the
available values for the property; for example:
[Inspectable(defaultValue="left", enumeration="left, right")]
function set labelPlacement(p:String)
...
In this example, the
labelPlacement
property is limited to the values
left
or
right
, and the
default value is
left
. For more information on using the Inspectable keyword, see
“Inspectable”
on page 63
. The ModalText example class file shows the use of the Inspectable keyword. For more
information, see
“Using the ModalText example” on page 73
.
Содержание FLEX - DEVELOPING COMPONENTS AND THEMES
Страница 1: ...Developing Flex Components and Themes in Flash Authoring ...
Страница 4: ...4 Contents ...
Страница 44: ...44 Chapter 2 Creating Basic Components in Flash MX 2004 ...
Страница 82: ...82 Index ...