`

———编写一个简单的程序

阅读更多
Because MXML files are ordinary XML files, you have a wide choice of development environments. You can write MXML code in a simple text editor, a dedicated XML editor, or an integrated development environment (IDE) that supports text editing. Flex supplies a dedicated IDE, called Adobe(R) Flex(TM) Builder(TM), that you can use to develop your applications.
    由于MXML文件是普通的XML文件,您可以选择多种开发环境。你可以在一个简单的文本编辑器中编写MXML代码,专门的XML编辑器,或者一个能支持文本编辑的集成开发环境(IDE)。Flex提供了一个专门的IDE工具,叫做Adobe(R) Flex(TM) Builder(TM),您可以使用它来开发您的程序。

The following example shows a simple “Hello World” application that contains just an <mx:Application> tag and two child tags, the <mx:Panel> tag and the <mx:Label> tag. The <mx:Application> tag defines the Application container that is always the root tag of a Flex application. The <mx:Panel> tag defines a Panel container that includes a title bar, a title, a status message, a border, and a content area for its children. The <mx:Label> tag represents a Label control, a very simple user interface component that displays text.
    以下展示的一个简单的“Hello World”程序,只包含了一个<mx:Application>标签和两个子标签,分别是<mx:Panel>和<mx:Label>。<mx:Application>定义了一个程序的容器,它总是作为Flex程序的根标签。<mx:Panel>标签定义了一个面板容器,其中包括标题栏,标题,状态信息,边界,还有一个可以装子节点的内容部分。<mx:Label>标签代表一个Label控件,一个非常简单的UI组件,用于显示文本。
<?xml version="1.0"?>
<!-- mxml\HellowWorld.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Panel title="My Application" 
        paddingTop="10" 
        paddingBottom="10"
        paddingLeft="10" 
        paddingRight="10"
    >
        <mx:Label text="Hello World!" fontWeight="bold" fontSize="24"/>
    </mx:Panel>
</mx:Application>

Save this code to a file named hello.mxml. MXML filenames must end in a lowercase .mxml file extension.
    将此代码保存为文件hello.mxml。MXML文件名必须以小写的.MXML扩展名结尾。

The following image shows the “Hello World” application rendered in a web browser window:
    下面的图片展示了“Hello World”程序在浏览器执行后的效果:



关于XML文件的编写

The first line of the document specifies an optional declaration of the XML version. It is good practice to include encoding information that specifies how the MXML file is encoded. Many editors let you select from a range of file encoding options. On North American operating systems, ISO-8859-1 is the dominant encoding format, and most programs use that format by default. You can use the UTF-8 encoding format to ensure maximum platform compatibility. UTF-8 provides a unique number for every character in a file, and it is platform-, program-, and language-independent.
    文件的第一行指定一个可选的XML版本声明。它包括编码信息,指定如何MXML文件进行编码。这是很好的做法。许多编辑器让你在文件开头就指定文件编码选项。在北美的操作系统中,ISO-8859-1是主要的编码格式,并且是大多数程序使用的默认格式。您可以使用UTF-8编码格式,以确保最大的平台兼容性。 UTF-8的提供了一个文件中的每个字符唯一的编号,是平台,项目和语言无关性的。

If you specify an encoding format, it must match the file encoding you use. The following example shows an XML declaration tag that specifies the UTF-8 encoding format:
    如果您指定了编码格式,您的文件使用必须符合文件编码的文字。下面的例子显示了一个XML声明标签,指定为UTF-8编码格式:
<?xml version="1.0" encoding="utf-8"?>



关于<mx:Application>标签


In addition to being the root tag of a Flex application, the <mx:Application> tag represents an Application container. A container is a user-interface component that contains other components and has built-in layout rules for positioning its child components. By default, an Application container lays out its children vertically from top to bottom. You can nest other types of containers inside an Application container, such as the Panel container shown above, to position user interface components according to other rules. For more information, see “Using Flex Visual Components” on page 113.
    <mx:Application>标签除了作为一个Flex应用程序的根标签,还代表了一个应用程序容器。容器是一个UI组件,其中包含其他组件,并拥有内置的布局规则定位其子组件。默认情况下,一个应用程序容器,将其子组件按照垂直方向从上到下的方式布局。在应用程序中也可以嵌套其他类型的容器内,如上面所述的面板容器,用来定位UI组件按照它自己的规则。更多有关信息,请参阅113页“使用Flex可视组件“。


About MXML tag properties
关于MXML标签的属性


The properties of an MXML tag, such as the text, fontWeight, and fontSize properties of the <mx:Label> tag, let you declaratively configure the initial state of the component. You can use ActionScript code in an <mx:Script> tag to change the state of a component at run time. For more information, see “Using ActionScript” on page 37.
    一个MXML标签的属性,是让你声明和配置组件的初始状态。如<mx:Label>标记中的fontWeight和fontSize属性。您也可以在<mx:Script>标签中使用ActionScript代码来
更改在运行时组件的状态。更多有关信息,请参阅第37页“使用ActionScript”。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics