加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex4中的皮肤(4)

发布时间:2020-12-15 04:42:54 所属栏目:百科 来源:网络整理
导读:Flex4 中的皮肤( 4 ):使用 SkinPart 约束 Skin 收藏 在 SkinnableComponent 中,可以声明 SkinPart 元标签对 Skin 进行约束,同时在组件中提供对 Skin 元素的引用: ? view plaincopy to clipboardprint? [SkinPart(required="false")]??????? ??? public

Flex4中的皮肤(4):使用SkinPart约束Skin 收藏

SkinnableComponent中,可以声明SkinPart元标签对Skin进行约束,同时在组件中提供对Skin元素的引用:

?

view plaincopy to clipboardprint?

[SkinPart(required="false")]??????? ???

public var labelElement:SimpleText;?

[SkinPart(required="false")]????????????

public var labelElement:SimpleText;

?

如果声明了SkinPart并且required="true",则Skin中必须包含该类型灯元素并且具有相同的id

?

<s:SimpleText id="labelElement" .../>

?

SkinnableComponent中还提供了partAddedpartRemoved方法:

?

view plaincopy to clipboardprint?

//--------------------------------------------------------------------------??

??? //??

??? //? Methods - Parts??

??? //??

??? //--------------------------------------------------------------------------??

??????

??? /**?

???? *? Called when a skin part is added.??

???? *? You do not call this method directly.??

???? *? For static parts,Flex calls it automatically when it calls the <code>attachSkin()</code> method.??

???? *? For dynamic parts,Flex calls it automatically when it calls??

???? *? the <code>createDynamicPartInstance()</code> method.??

???? *?

???? *? <p>Override this function to attach behavior to the part.??

???? *? If you want to override behavior on a skin part that is inherited from a base class,??

???? *? make sure that you do not call the <code>super.partAdded()</code> method.??

???? *? Otherwise,you should always call the <code>super.partAdded()</code> method.</p>?

???? *?

???? *? @param partname The name of the part.?

???? *?

?? ??*? @param instance The part.?

???? *???

???? *? @langversion 3.0?

???? *? @playerversion Flash 10?

???? *? @playerversion AIR 1.5?

???? *? @productversion Flex 4?

???? */?

??? protected function partAdded(partName:String,instance:Object):void?

??? {?????

??? }??

??? /**?

???? *? Called when an instance of a skin part is being removed.??

???? *? You do not call this method directly.??

???? *? For static parts,Flex calls it automatically when it calls the <code>detachSkin()</code> method.??

???? *? For dynamic parts,Flex calls it automatically when it calls??

???? *? the <code>removeDynamicPartInstance()</code> method.??

???? *?

???? *? <p>Override this function to remove behavior from the part.</p>?

???? *?

???? *? @param partname The name of the part.?

???? *?

???? *? @param instance The part.?

???? *???

???? *? @langversion 3.0?

???? *? @playerversion Flash 10?

???? *? @playerversion AIR 1.5?

???? *? @productversion Flex 4?

???? */?

??? protected function partRemoved(partName:String,instance:Object):void?

??? {?????????

??? }??

?????

//--------------------------------------------------------------------------

??? //

??? //? Methods - Parts

??? //

??? //--------------------------------------------------------------------------

???

??? /**

???? *? Called when a skin part is added.

???? *? You do not call this method directly.

???? *? For static parts,Flex calls it automatically when it calls the <code>attachSkin()</code> method.

???? *? For dynamic parts,Flex calls it automatically when it calls

???? *? the <code>createDynamicPartInstance()</code> method.

???? *

???? *? <p>Override this function to attach behavior to the part.

???? *? If you want to override behavior on a skin part that is inherited from a base class,

???? *? make sure that you do not call the <code>super.partAdded()</code> method.

???? *? Otherwise,you should always call the <code>super.partAdded()</code> method.</p>

???? *

???? *? @param partname The name of the part.

???? *

???? *? @param instance The part.

???? *?

???? *? @langversion 3.0

???? *? @playerversion Flash 10

???? *? @playerversion AIR 1.5

???? *? @productversion Flex 4

???? */

??? protected function partAdded(partName:String,instance:Object):void

??? {??

??? }

??? /**

???? *? Called when an instance of a skin part is being removed.

???? *? You do not call this method directly.

???? *? For static parts,Flex calls it automatically when it calls the <code>detachSkin()</code> method.

???? *? For dynamic parts,Flex calls it automatically when it calls

???? *? the <code>removeDynamicPartInstance()</code> method.

???? *

???? *? <p>Override this function to remove behavior from the part.</p>

? ???*

???? *? @param partname The name of the part.

???? *

???? *? @param instance The part.

???? *?

???? *? @langversion 3.0

???? *? @playerversion Flash 10

???? *? @playerversion AIR 1.5

???? *? @productversion Flex 4

???? */

??? protected function partRemoved(partName:String,instance:Object):void

??? {??????

??? }

????

?

在增加或删除SkinPart时会调用这些方法。

?

通过重写这些方法可以对SkinPart进行额外的操作,比如增加SkinPart时为其添加事件监听:

?

view plaincopy to clipboardprint?

override protected function partAdded(partName:String,instance:Object) : void?

{??

?????? super.partAdded(partName,instance);??

?????? if (instance == labelElement)??

?????????? labelElement.addEventListener(...);??

}?

?

?

?

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ThinkInside/archive/2009/10/06/4635138.aspx

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读