Flex 4.5 使用ActionScript创建item renderer

 

使用AS创建item renderer

有以下方法用于创建AS item render:

实现一个item renderer需要覆盖必要的方法,和调用必要的 invalidation方法,具体取决于继承的父类。可选的覆盖以下方法:

Method

Description

commitProperties()

Commits any changes to component properties, either to make the changes occur at the same time or to ensure that properties are set in a specific order.

For more information, see Implementing the commitProperties() method.

createChildren()

Creates any child components of the component. For example, the ComboBox control contains a TextInput control and a Button control as child components.

For more information, see Implementing the createChildren() method.

measure()

Sets the default size and default minimum size of the component.

For more information, see Implementing the measure() method.

styleChanged()

Detects changes to style properties.

For more information, see Overriding the styleChanged() method.

updateDisplayList()

Sizes and positions the children of the component on the screen based on all previous property and style settings, and draws any skins or graphic elements used by the component. The parent container for the component determines the size of the component itself.

Note: You typically only have to implement this method when you use the mx.core.UIComponent class as the base class of your item renderer. You do not have to implement it when creating a subclass of the LabelItemRenderer class. Override LabelItemRenderer.drawBackground() and  LabelItemRenderer.layoutContent() instead.

For more information, see Implementing the updateDisplayList() method.



如果父类是LabelItemRenderer,可能会覆盖以下方法:

Method

Description

drawBackground()

Defines the background display of the item renderer.

layoutContents()

Lays out the children of the item renderer.


使用 invalidation机制需要用到以下方法:

Invalidation method

Description

invalidateProperties()

Marks a component so that its commitProperties() method gets called during the next screen update.

invalidateSize()

Marks a component so that its measure() method gets called during the next screen update.

invalidateDisplayList()

Marks a component so that its updateDisplayList() methods get called during the next screen update.





创建LabelItemRenderer的子类
覆盖 drawBackground()或者 layoutContents()方法。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值