posts - 325,  comments - 25,  trackbacks - 0

          內嵌資源:

            圖片
           a) 內聯方式內嵌:<mx:Button label="my button" icon="@Embed(source='myImage.gif')"/>
           b) 使用ActionScript綁定
              <mx:Script>
                  <![CDATA[
                          [Embed(source="myImage.gif")]
                          [Bindable]
                          public var imaCls:Class;
                  ]]>
              </mx:Script>
              <mx:Button label="my button" icon="{imgCls}"/>
          swf和音頻文件
              <mx:script>
                 <![CDATA[
                  [Embed(source="mySound.mp3")]
                  [Bindable]
                  public var mySound:Class;

                  [Embed(source="mySWF.swf")]
                  [Bindable]
                  public var mySWF:Class;
                 ]]>
              </mx:script>




          Flex 打印
          基本打印:
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script>
            <![CDATA[
            import mx.printing.FlexPrintJob;   
            private function print():void {
              // create print job
              var printJob:FlexPrintJob = new FlexPrintJob();
              if(printJob.start()){
                // add page
                printJob.addObject(myLabel,"none");
                // send to printer
                printJob.send();
              }
            }
            ]]>
            </mx:Script>
            <mx:Label id="myLabel" text="Hello World" />
            <mx:Button click="print()" label="Print" />
          </mx:Application>

          打印多頁
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
            <mx:Script>
              <![CDATA[
                import mx.printing.FlexPrintJob;
               private function print():void {
                // create print job
                 var printJob:FlexPrintJob = new FlexPrintJob();
                 if(printJob.start()){
                  // add 2 pages
                   printJob.addObject(page1,"none");
                    printJob.addObject(page2,"none");
                    // send to printer
                   printJob.send();
                 }
               }
              ]]>
            </mx:Script>
            <mx:Label id="page1" text="Hello World page 1" />
            <mx:Label id="page2" text="Hello World page 2" />
            <mx:Button click="print()" label="Print" />
          </mx:Application>

          打印表格數據
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="initData()">
            <mx:Script>
              <![CDATA[
              import mx.collections.ArrayCollection;
              import mx.printing.FlexPrintJob;
              [Bindable]
              public var dp:ArrayCollection;
              // populate the dataProviders for the datagrids
              private function initData():void{
                this.dp = new ArrayCollection();
                for(var i:Number=0; i<60; i++){
                  this.dp.addItem({row:i,data:"item " + i});
                }
              }
              public function print():void {
                // create print job
                var printJob:FlexPrintJob = new FlexPrintJob();
                // start print job
                if(printJob.start()){
                  // add the print grid
                  printJob.addObject(printGrid);
                  while(true) {
                    // loop through print grids data and add additonal pages if neccessary
                    printGrid.nextPage();
                    if(!printGrid.validNextPage){
                      printJob.addObject(printGrid);
                      break;
                    }
                  }
                  // send to printer
                  printJob.send();
                }
              }
              ]]>
            </mx:Script>
            <mx:DataGrid id="dataGrid" dataProvider="{dp}" height="200" width="200">
              <mx:columns>
                <mx:DataGridColumn dataField="row" headerText="Row Number" />
                <mx:DataGridColumn dataField="data" headerText="Row Data" />
              </mx:columns>
            </mx:DataGrid>
            <mx:Button click="print()" label="Print" />
            <mx:PrintDataGrid visible="false" id="printGrid" dataProvider="{dp}" height="700" width="600">
              <mx:columns>
                <mx:DataGridColumn dataField="row" headerText="Row Number" />
                <mx:DataGridColumn dataField="data" headerText="Row Data" />
              </mx:columns>
            </mx:PrintDataGrid>
          </mx:Application>

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

           

          長春語林科技歡迎您!

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 泉州市| 沾化县| 铜梁县| 龙里县| 泉州市| 会理县| 措勤县| 平乡县| 吉木乃县| 宜君县| 江陵县| 全椒县| 芮城县| 海兴县| 米易县| 东至县| 湟中县| 肇东市| 阿克陶县| 滨州市| 志丹县| 任丘市| 黔西县| 天祝| 武义县| 红安县| 林周县| 房产| 泰宁县| 建瓯市| 青州市| 郁南县| 呈贡县| 拉萨市| 巴马| 贵定县| 井冈山市| 嫩江县| 吉木乃县| 凯里市| 淮安市|