Working With Component Properties - MACROMEDIA FLEX - DEVELOPING COMPONENTS AND THEMES Manual

Developing flex components and themes in flash authoring
Table of Contents

Advertisement

Copy the SWC file that you created (BlueButton.swc) to the same directory as the MXML file.
23.
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.
Request the MXML file in your browser or a stand-alone Flash Player. The blue button should
24.
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
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
default value is
left
on page
63. The ModalText example class file shows the use of the Inspectable keyword. For more
information, see
30
Chapter 2: Creating Basic Components in Flash MX 2004
undefined
property is limited to the values
labelPlacement
. For more information on using the Inspectable keyword, see
"Using the ModalText example" on page
, or the user could encounter unexpected results.
73.
or
, and the
left
right
"Inspectable"

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLEX - DEVELOPING COMPONENTS AND THEMES and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flex

Table of Contents