`

———理解Flex的程序结构

阅读更多
You can write an MXML application in a single file or in multiple files. You typically define a main file that contains the <mx:Application> tag. From within your main file, you can then reference additional files written in MXML, ActionScript, or a combination of the two languages.
A common coding practice is to divide your Flex application into functional units, or modules, where each module performs a discrete task. In Flex, you can divide your application into separate MXML files and ActionScript files, where each file corresponds to a different module. By dividing your application into modules, you
provide 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  You can isolate and debug errors faster than if your application is developed in a single file.
In Flex, a module corresponds to a custom component implemented either in MXML or in ActionScript. These custom components can reference other custom components. There is no restriction on the level of nesting of component references in Flex. You define your components as required by your application.

    您可以将一个MXML应用程序写在一个或多个文件中。通常定义一个包含<mx:Application>标签的主文件。然后您可以从您的主文件中,引入其他MXML文件,ActionScript,或者是两种语言的结合。
    一个通常的编程方法,是将Flex程序按照功能划分为单元或模块,每个模块执行一个单独的任务。在Flex中,您可以将您的应用程序分成独立的MXML文件和ActionScript文件,每个文件对应到不同的模块。将功能分成模块会为您的应用程序提供许多好处,包括以下内容:
易于开发 不同的开发人员或开发小组可以独立于彼此来进行模块的开发和调试。
可重用性 您可以在不同的应用程序中使用您的模块,使您不必做重复性的工作。
可维护性 相比于您将应用程序写在一个文件中,分成模块的方式可以更快的将错误分离出来并加以调试
    Flex中,可以在MXML或ActionScript中实现对应一个模块的自定义组件。这些自定义组件可以引用其他自定义组件。目前,关于Flex组件的引用和嵌套级别并没有限制。您可根据您的应用程序的需求来定义您的组件。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics