MACROMEDIA COLDFUSION MX 7.0.2-USING COLDFUSION MX WITH FLEX 2 Guida Utente Pagina 97

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 256
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 96
Creating ActionScript components 97
Creating ActionScript components
You create reusable components using ActionScript, and reference these components in your
Flex applications as MXML tags. Components created in ActionScript can contain graphical
elements, define custom business logic, or extend existing Flex components. They can inherit
from any components available in Flex.
Defining your own components in ActionScript has several benefits. Components let you
divide your applications into individual modules that you can develop and maintain
separately. By implementing commonly used logic within custom components, you can build
a suite of reusable components that you can share among multiple Flex applications.
In addition, you can base your custom components on the set of Flex components by
extending from the Flex class hierarchy. You can create custom versions of Flex visual controls,
as well as custom versions on nonvisual components, such as data validators, formatters, and
effects.
For example, you can define a custom button, derived from the Flex Button control, as the
following example shows:
// using_actionscript/myControls/MyButton.as
package myControls {
import mx.controls.Button;
public class MyButton extends Button {
public function MyButton() {
}
}
}
In this example, you write your MyButton control to the MyButton.as file, and you store the
file in the myControls subdirectory of the root directory of your Flex application. The
package name of your component reflects its location. In this example, the component’s
package name is
myControls.
You can reference your custom Button control from a Flex application file, such as
MyApp.mxml, as the following example shows:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:cmp="myControls.*">
<cmp:MyButton label="Click Me"/>
</mx:Application>
Vedere la pagina 96
1 2 ... 92 93 94 95 96 97 98 99 100 101 102 ... 255 256

Commenti su questo manuale

Nessun commento