組件的重構
系統
1762 0
組件的重構
1. 新建組件 File-New-MXML Conponent
為組件添加一個myProperty屬性和一個標簽,并將標簽與屬性綁定,組件代碼如下:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
<mx:Script>
<![CDATA[
[Bindable]
public var myProperty:String;
]]>
</mx:Script>
<mx:Label x="151" y="129" text="{myProperty}"/>
</mx:Canvas>
2.返回應用程序文件,將組件導入 xmlns:local=”*” 并將組件添加到容器里,設置組件的屬性值
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
xmlns:local="*">
<local:FirstConponent id="myConponent" myProperty="ddd"/>
</mx:Application>
3.修改組件文件名
點擊Rename
然后到應用程序文件查看,是否已經自動將組件名修改:
<local:MyFirstConponent id="myConponent" myProperty="ddd"/>
4.修改組件的屬性名,在組件代碼里選中屬性名,右擊
[img]http://dl.iteye.com/upload/picture/pic/85611/a45461c2-89e6-3148-b8cc-ea495ba1547c.jpg [/img]
然后返回到應用程序文件,查看組件的屬性是否已經自動修改
<local:MyFirstConponent id="myFirstConponent" myFirstProperty="ddd"/>
組件的重構
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061
微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元