posts - 325,  comments - 25,  trackbacks - 0

          數(shù)據(jù)模型
          基本數(shù)據(jù)模型:
          使用<mx:Model>標(biāo)簽和嵌套的xml結(jié)構(gòu)實現(xiàn)
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
             backgroundColor="#FFFFFF">
            <mx:Model id="contactmodel">
              <contact>
                <fname>Rich</fname>
                <lname>Tretola</lname>
                <address>101 Skye St.</address>
                <city>Anytown</city>
                <state>NY</state>
                <zip>11111</zip>
                <phone>5165559999</phone>
                <email>proflex2@gmail.com</email>
              </contact>
            </mx:Model>
            <mx:Panel title="Contact Info" width="200" height="170">
              <mx:Label text="{contactmodel.fname} {contactmodel.lname}" />
              <mx:Label text="{contactmodel.address}" />
              <mx:Label text="{contactmodel.city} {contactmodel.state}, {contactmodel.zip}" />
              <mx:Label text="{contactmodel.phone}" />
              <mx:Label text="{contactmodel.email}" />
            </mx:Panel>
          </mx:Application>
          也可將xml文件提取了出來,
          Contace.xml
          <?xml version="1.0"?>
          <contact>
            <fname>Rich</fname>
            <lname>Tretola</lname>
            <address>101 Skye St.</address>
            <city>Anytown</city>
            <state>NY</state>
            <zip>11111</zip>
            <phone>5165559999</phone>
            <email>proflex2@gmail.com</email>
          </contact>

          使用<mx:Model>綁定Contact.xml文件
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
             backgroundColor="#FFFFFF">
            <mx:Model source="Contact.xml" id="contactmodel"/>
            <mx:Panel title="Contact Info" width="200" height="170">
              <mx:Label text="{contactmodel.fname} {contactmodel.lname}" />
              <mx:Label text="{contactmodel.address}" />
              <mx:Label text="{contactmodel.city} {contactmodel.state}, {contactmodel.zip}" />
              <mx:Label text="{contactmodel.phone}" />
              <mx:Label text="{contactmodel.email}" />
            </mx:Panel>
          </mx:Application>

          使用<mx:XML >綁定Contact.xml文件
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
             backgroundColor="#FFFFFF">
            <mx:XML source="Contact.xml" id="contactmodel"/>
            <mx:Panel title="Contact Info" width="200" height="170">
              <mx:Label text="{contactmodel.fname} {contactmodel.lname}" />
              <mx:Label text="{contactmodel.address}" />
              <mx:Label text="{contactmodel.city} {contactmodel.state}, {contactmodel.zip}" />
              <mx:Label text="{contactmodel.phone}" />
              <mx:Label text="{contactmodel.email}" />
            </mx:Panel>
          </mx:Application>

          將數(shù)據(jù)模型綁定到自定義組件
          包括公共[Bindable]變量contactmodel(Object類型)的VBOX容器
          <?xml version="1.0" encoding="utf-8"?>
          <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
           <mx:Script>
            <![CDATA[
             [Bindable]
             public var contactmodel:Object;
            ]]>
           </mx:Script>
           <mx:Label text="{contactmodel.fname} {contactmodel.lname}" />
            <mx:Label text="{contactmodel.address}" />
            <mx:Label text="{contactmodel.city} {contactmodel.state}, {contactmodel.zip}" />
            <mx:Label text="{contactmodel.phone}" />
            <mx:Label text="{contactmodel.email}" />
          </mx:VBox>
          使用<mx:Model>和自定義組件綁定Contact.xml文件
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
             backgroundColor="#FFFFFF" xmlns:comps="*">
            <mx:Model source="Contact.xml" id="contactmodel"/>
            <mx:Panel title="Contact Info" width="200" height="170">
              <comps:Contact contactmodel="{this.contactmodel}" />
            </mx:Panel>
          </mx:Application>

          綁定兩個xml文件
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
             backgroundColor="#FFFFFF" xmlns:comps="*">
            <mx:Model source="Contact.xml" id="contactmodel"/>
            <mx:Model source="Contact2.xml" id="vacationmodel"/>
            <mx:Panel title="Contact Info" width="300" height="170" layout="horizontal">
              <comps:Contact contactmodel="{this.contactmodel}" />
              <mx:Spacer width="20" />
              <comps:Contact contactmodel="{this.vacationmodel}" />
            </mx:Panel>
          </mx:Application>

          posted on 2011-03-16 15:39 長春語林科技 閱讀(205) 評論(0)  編輯  收藏 所屬分類: flex
          <2011年3月>
          272812345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

           

          長春語林科技?xì)g迎您!

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 十堰市| 乌鲁木齐市| 盈江县| 南京市| 克山县| 新沂市| 揭东县| 康平县| 鹤峰县| 工布江达县| 祁东县| 呼图壁县| 砀山县| 鱼台县| 萨迦县| 通道| 城市| 莫力| 新津县| 镇坪县| 岑巩县| 遂溪县| 鸡西市| 墨江| 会泽县| 浠水县| 遂川县| 靖州| 淮北市| 阿瓦提县| 丰城市| 区。| 公主岭市| 蛟河市| 汤阴县| 壤塘县| 吴江市| 万安县| 常宁市| 同仁县| 泾川县|