flex 常用元标签讲解

本文转自  flex 常用元标签讲解

    Flex 引入了元数据标签的概念,大多数人都使用过的 [Bindable] 标签便是其中的 meta tag 之一,它在代码中的作用就是向编译器提供如何编译程序的信息。实际上,这些标签并没有被编译到生成的 SWF 文件中,而只是告诉编译器如何生成 SWF 文件。

adobe 官网 http://livedocs.adobe.com/flex/3/html/help.html?content=metadata_3.html详细讲解了 16种meta 的使用,简单如下表所示。

Tag

Description

[ArrayElementType]

Defines the allowed data type of each element of an Array.

[Bindable]

Identifies a property that you can use as the source of a data binding expression.

[DefaultProperty]

Defines the name of the default property of the component when you use the component in an MXML file.

[Deprecated]

Marks a class or class element as deprecated so that the compiler can recognize it and issue a warning when the element is used in an application.

[Effect]

Defines the MXML property name for the effect.

[Embed]

Imports JPEG, GIF, PNG, SVG, and SWF files at compile time. Also imports image assets from SWC files.

[Event]

Defines the MXML property for an event and the data type of the event object that a component emits.

[Exclude]

Omits the class element from the Flex Builder tag inspector. The syntax is as follows:[Exclude(name="label", kind="property")]

[ExcludeClass]

Omits the class from the Flex Builder tag inspector. This is equivalent to the @private tag in ASDoc when applied to a class.

[IconFile]

Identifies the filename for the icon that represents the component in the Insert bar of Adobe Flex Builder.

[Inspectable]

Defines an attribute exposed to component users in the attribute hints and Tag inspector of Flex Builder. Also limits allowable values of the property.

[InstanceType]

Specifies the allowed data type of a property of type IDeferredInstance.

[NonCommittingChangeEvent]

Identifies an event as an interim trigger.

[RemoteClass]

Maps the ActionScript object to a Java object.

[Style]

Defines the MXML property for a style property for the component.

[Transient]

Identifies a property that should be omitted from data that is sent to the server when an ActionScript object is mapped to a Java object using [RemoteClass].

       本人认为,这其中常用的 Bindable , Embed , RemoteClass 这 3 种(本人是从开发业务程序角度来考虑, effect 等 ui 效果就暂且忽略了)。

1、  Bindable 标签

Bindable 标签应该是使用率最高的标签,其功效就是将某个变量或者属性绑定到目标对象上,比如业务应用经常要操作 datagrid ,此时就需将变量绑定到 datagrid.dataprovider 上,通过变量操作来显示 datagrid 的数据变动。

    [ Bindable ]

private var transWayLists:ArrayCollection;

...

<mx:AdvancedDataGrid dataProvider="{ transWayLists }"/>

2、  RemoteClass 标签

该标签用以映射 flex object 到 java object ,因此在写 flex 程序与 java 程序交互之时特别有用,比如 flex 登录程序总需发送登录信息到 java 登录服务,然后 java 登录服务通过验证返回登录用户信息,此时就需 flex user映射到 java user ,如下:

flex :

    [ Bindable ]

    [RemoteClass ( alias="com. marcus .User" )]

    public class User

    {

       public var   userId:String;

       public var businessId:String;

       public var   userName:String;

       public var password:String;

    public var passTimeout:Date;

    ...

}

java:

package com.marcus;

import java.util.Date;

public class User {

    private String userId;

    private String businessId;

    private String userName;

    private String password;

    private Date passTimeout;

    ...

}

3、  Embed 标签

该标签用以嵌入 jpg 等资源文件,并在编译的时候生成到 swf 文件中,因此嵌入资源文件过大时,会影响swf 加载速度。

[Embed(source='home.png')]      // 绑定图片home.png 给home_icon 类

private var home_icon:Class;

 

4、  ArrayElementType 标签

该标签用以标识数组中元素的数据类型,该 meta tag 并未列入本人的常用 meta tag 之一,为何还要强调的原因就是本人认为 ArrayElementType 标签就是一个鸡肋标签,狗屁不是,建议大家慎用。


已经博主授权,源码转载自 https://pan.quark.cn/s/a4b39357ea24 在信息技术领域,特别是软件编程行业,微软公司推出的集成开发环境(IDE)Visual Studio,凭借其卓越的功能和广泛的适用范围,成为了众多程序员的常用工具。不过,在实际操作期间,用户可能会遭遇各种挑战,其中一种较为普遍的挑战是“Visual Studio遭遇了异常情况,这或许与某个附加组件有关”。本文将详细研究这一现象的成因、潜在后果以及最终的应对措施。 ### 原因剖析 Visual Studio通过支持多种插件和附加组件来扩展其功能,这些组件通常由第三方开发者设计,旨在为用户提供更多个性化和专业化的工具。然而,这些插件的质量良莠不齐,部分可能未经过充分的测试或与特定版本的Visual Studio存在兼容性难题,从而在执行时引发异常。异常的出现可能源于以下几个因素: 1. **代码缺陷**:若附加组件中的代码存在逻辑问题或资源管理不当,就可能导致运行时异常。 2. **资源竞争**:多个插件同时占用相同的资源(例如内存、文件句柄等),可能会产生资源冲突,进而触发异常。 3. **依赖不匹配**:插件可能需要特定版本的库或框架,如果系统中安装的版本不一致,也可能导致异常。 4. **安全隐患**:部分插件可能存在安全漏洞,一旦被恶意利用,可能会导致更严重的问题,包括但不限于异常崩溃。 ### 后果分析 当Visual Studio遇到由附加组件引发的异常时,不仅会中断当前的工作进程,降低开发效能,还可能带来以下潜在风险: 1. **数据遗失**:若异常发生在保存操作之前,可能会导致未保存的工作内容遗失。 2. **稳定性减弱**:频繁的异常会导致Visual Stud...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值