Macromedia flex 2 Manuale

Pagina di 254
14
Creating Flex Components
A common coding practice is to divide an application into functional units, or modules, 
where each module performs a discrete task. Dividing your application into modules provides 
you with many benefits, including the following:
Ease of development
Different developers or development groups can develop and debug 
modules independently of each other. 
Reusability
You can reuse modules in different applications so that you do not have to 
duplicate your work.
Maintainability
By developing your application in discrete modules, you can isolate and 
debug errors faster than you could if you developed your application in a single file. 
In Flex, a module corresponds to a custom component, implemented either in MXML or in 
ActionScript. The following image shows an example of a Flex application divided into 
components:
<..>
<..>
ActionScript 
classes
SWC and RSL files
*.AS
*.AS
*.AS
*.SWF
RSL files
Client
Web server
Compiler/Linker
Custom 
components
main.mxml
Use <mx:Script> 
to write, import, 
or include 
ActionScript
*.MXML
*.AS
*.MXML
<mx:Application>
*.AS