佳麗斯 加厚雙人/單人秋冬被子暖冬 羊毛被芯羊毛柔絲被特價包郵 憂憂魚冬外穿打底褲女秋冬厚長褲女褲加絨加厚高腰彈力鉛筆褲靴褲 韓國代購2013新款 韓版秋冬休閑女時尚磨破口袋衛衣韓版學生裝 潮

          有時,退一步,能一口氣進幾步,只是這先退一步需要勇氣和自信。

          用心愛你,努力工作。

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            70 隨筆 :: 1 文章 :: 33 評論 :: 0 Trackbacks

              今天做了個關于flex與動態語言通信的小例子。flex做web的前臺的確效果很cool,對web程序員來說,首先要掌握flex與jsp,php等等動態語言之間的通信細節。其實也很簡單,搞了個例子,有興趣的朋友可以看一下。
              因為我的機器上只裝了php的開發環境,所以以php為例子來說明。
              以下先介紹第一種通信方式:HTTPService
          1.建立HttpDemo.mxml,

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FD1D06, #EAF807]" height="328" width="428">
             <mx:HTTPService
              showBusyCursor="true" 
              id="loginSrv"
              result="doResult();" 
                 method="GET"
              url="http://localhost/test.php">
             <mx:request>
              <username> 
               {txtname.text}
              </username>
              <userpassword>
              {txtpwd.text}
              </userpassword>
             </mx:request>
           </mx:HTTPService>
           
           
           <mx:Script>
            <![CDATA[
            
             import mx.controls.Alert;

             internal function doResult():void
             {
              var returnValue:String=loginSrv.lastResult.Result.msg;
                    if(returnValue=="success")
                { 
                this.currentState="login";
                    } 
               else
                 { 
               Alert.show("您的登錄失敗了","提示信息",Alert.OK,this,null,null,Alert.YES);
                         }
             }
            ]]>
           </mx:Script>


          <mx:states >
           <mx:State id="s1"  name="login">
            <mx:RemoveChild target="{btnSubmit}"/>
            <mx:RemoveChild target="{txtname}"/> 
            <mx:RemoveChild target="{txtpwd}"/>
            <mx:RemoveChild target="{txtpwd}"/>
            <mx:RemoveChild target="{lbname}"/>
            <mx:RemoveChild target="{lbpwd}"/>
                  <mx:AddChild relativeTo="{loginPanel}" position="lastChild">
                     <mx:target>
                         <mx:Label text="你已經成功登陸!" x="64" y="33" fontSize="16" textAlign="center" fontStyle="normal" fontWeight="bold" textDecoration="normal" color="#1031AB"/>
                     </mx:target>          
            </mx:AddChild>
                  <mx:SetProperty target="{loginPanel}" name="title" value="登陸成功"/>
                  <mx:AddChild relativeTo="{loginPanel}" position="lastChild">
                   <mx:Button x="95.5" y="83" label="退出登陸" click="currentState=''"/>
                  </mx:AddChild>
            
           </mx:State>
           
          </mx:states>

           <mx:Panel id="loginPanel" x="69.5" y="57" width="289" height="200" layout="absolute" title="登陸" fontSize="12">
            <mx:Button x="110" y="108" label="提交" id="btnSubmit" click="loginSrv.send();"/>
            <mx:TextInput x="79" y="30" fontSize="12" id="txtname"/>
            <mx:TextInput x="79" y="62" id="txtpwd"/>
            <mx:Label x="21" y="32" text="姓名:" id="lbname" fontSize="12" fontWeight="bold"/>
            <mx:Label x="21" y="64" text="密碼:" id="lbpwd" fontSize="12" fontWeight="bold"/>
           </mx:Panel>
           
          </mx:Application>

          2.建立test.php,放到php開發的根目錄下

          <?php
               $str="<Result><msg>success</msg></Result>";
               echo $str;
          ?>    

          在flex builder3運行HttpDemo.mxml,即可以看到效果。


          posted on 2008-10-15 22:25 王生生 閱讀(654) 評論(0)  編輯  收藏 所屬分類: Flex
          森露2013新款豹紋打底衫 高領 女 長袖 修身長袖t恤女 加絨加厚冬 2013春秋新款女裝 潮修身大碼長袖小西裝外套女 韓版中長款小西裝 憂憂魚2013秋冬新款直筒褲女顯瘦長褲加絨黑色休閑褲修身西褲女褲
          主站蜘蛛池模板: 富顺县| 怀安县| 加查县| 凌源市| 田林县| 安阳县| 习水县| 响水县| 尖扎县| 巴彦淖尔市| 枝江市| 皋兰县| 桦南县| 景德镇市| 汶川县| 康保县| 祁连县| 乐都县| 榕江县| 彭阳县| 泸定县| 东兰县| 泰和县| 永新县| 时尚| 洛扎县| 金门县| 南宫市| 车险| 卢氏县| 河津市| 濮阳县| 乌拉特前旗| 阿尔山市| 唐山市| 隆子县| 东丰县| 晴隆县| 全椒县| 神木县| 左权县|