flex 开发卡片保存产品(四)

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="466" height="190" creationComplete="initUI();" alpha="1.0"  borderColor="#F1F5F5" backgroundColor="#DFE8EE">
  3. <mx:Script>
  4.     <![CDATA[
  5.         import code.ProductHandlerBasic;
  6.         import mx.formatters.DateFormatter;
  7.         import mx.controls.Label;
  8.         import mx.managers.PopUpManager; 
  9.         
  10.         private var _recordid:Number ;
  11.         private var _productContent:String ;
  12.         private var _previewURL:String ;
  13.         private var _productid:Number ;
  14.         private var _phander:ProductHandlerBasic ;
  15.         
  16.         private function initUI():void{
  17.             sendProductNameReq() ;
  18.         }
  19.         public function set productHanderBasic(p:ProductHandlerBasic):void{
  20.             this._phander = p ;
  21.         } 
  22.         public function get productHanderBasic():ProductHandlerBasic{
  23.             return _phander ;
  24.         }
  25.         /**********保存产品***************************/
  26.         private function sendSaveproductReq():void{
  27.             if(productNameID.text==null||productNameID.text==""){
  28.                 return ;
  29.             }
  30.             bt1.label= "保存中...";
  31.             //===保存当前输入的产品名称
  32.             //photobook68.MAIN._productName = productNameID.text ;
  33.              
  34.             bt1.enabled = false ;
  35.             
  36.             var paras:Object = new Object(); 
  37.             paras.methodName = "saveProductHanlder" ;
  38.             paras.pid = _phander.recordID ;
  39.             paras.productname = productNameID.text ;
  40.             paras.randow = Math.random() ; 
  41.             paras.productid = _phander.productID ;
  42.             paras.classid= _phander.classid  ; 
  43.             paras.content = _phander.productDataContent.toXMLString() ;
  44.             paras.previewURL = _phander.previewURL ;
  45.             saveProductID.send(paras); 
  46.         }
  47.         
  48.         /*********保存产品,返回结果****************/
  49.         private function getProductSaveResult():void{
  50.             
  51.             _phander.recordID = saveProductID.lastResult.toString() ;
  52.              
  53.             title1.removeAllChildren() ;
  54.             var lb:Label = new Label() ;
  55.             lb.x = 30;
  56.             lb.y = 30 ;   
  57.             lb.text = "您的作品已经成功保存,可到/"我的相册->保存的礼物/"中查看。";
  58.             lb.setStyle("fontSize","12");
  59.             title1.addChild(lb) ;
  60.             var bt:Button = new Button() ;
  61.             bt.label = "确定"
  62.             bt.width = 80 ; 
  63.             bt.setStyle("fontSize","12");
  64.             bt.height = 30 ;
  65.             bt.setStyle("cornerRadius","2");
  66.             bt.setStyle("fontWeight","normal");
  67.             bt.x=167 ; 
  68.             bt.y=88 ; 
  69.             bt.addEventListener(MouseEvent.CLICK,saveOk) ;
  70.             this.title1.addChild(bt);
  71.             
  72.             var bt2:Button = new Button() ;
  73.             bt2.label = "查看作品"
  74.             bt2.width = 80 ; 
  75.             bt2.setStyle("fontSize","12");
  76.             bt2.setStyle("fontWeight","normal");
  77.             bt.setStyle("cornerRadius","2");
  78.             bt2.x=261 ;   
  79.             bt2.y=88 ;  
  80.             bt2.height = 30 ;
  81.                
  82.             bt2.addEventListener(MouseEvent.CLICK,viewProduct) ;
  83.             this.title1.addChild(bt2);
  84.         }  
  85.          
  86.         /**==============成功保存作品====================**/ 
  87.         private function saveOk(e:MouseEvent):void{
  88.               //photobook68.MAIN.deleteAlphaBackground(); 
  89.               
  90.               this.removeEventListener(MouseEvent.CLICK,saveOk);
  91.               this.removeEventListener(MouseEvent.CLICK,viewProduct);
  92.              // this.parent.removeChild(this) ;
  93.               PopUpManager.removePopUp(this) ;
  94.         }
  95.         
  96.         /**==============查看作品====================**/
  97.         private function viewProduct(e:MouseEvent):void{
  98.             var url:String = "/pages/product/newPhotoBook/productrecord_index.faces" ;
  99.             var request:URLRequest = new URLRequest(url);  
  100.             navigateToURL(request,"_self");   
  101.         }
  102.         
  103.         
  104.         /*********取消保存****************/
  105.         private function cancleHandler():void{
  106.             //photobook68.MAIN.deleteAlphaBackground();
  107.             //this.parent.removeChild(this) ;
  108.             PopUpManager.removePopUp(this);
  109.         }
  110.          
  111.         /*********请求获取产品名称****************/
  112.         private function sendProductNameReq():void{
  113.             //=========第一次做产品,还没有产品名称
  114.             if(_phander.recordID==-1){
  115.                 var f:DateFormatter = new DateFormatter() ;
  116.                 f.formatString = "YYYYMMDD" ;   
  117.                 this.productNameID.text = "我的个性卡片"+f.format(new Date());
  118.             }else{
  119.             //=========编辑产品时 
  120.                 var obj:Object = new Object() ;
  121.                 obj.methodName = "getProductName";  
  122.                 obj.randow = Math.random() ;
  123.                 obj.pid = _phander.recordID ;
  124.                 productnameservice.send(obj) ;
  125.             } 
  126.         
  127.         }
  128.         /*********取得已经保存产品的名称****************/
  129.         private function reveiveProductNameRes():void{
  130.             this.productNameID.text = productnameservice.lastResult.toString() ;
  131.         }
  132.           
  133.     ]]>
  134. </mx:Script>
  135.     <mx:TitleWindow id="title1" x="0" y="0" width="100%" height="100%" layout="absolute" title="作品保存" showCloseButton="false" fontSize="12"  borderColor="#F1F5F5" alpha="1.0" backgroundColor="#F1F5F5" cornerRadius="0">
  136.         <mx:Label x="10" id="id1" y="29" width="122" text="输入您的作品名称:" fontWeight="bold" fontFamily="Courier New" color="#6C6868"/>
  137.         <mx:TextInput   x="151" y="29"  borderStyle="solid"  borderThickness="2" height="22" width="188" id="productNameID" />
  138.         <mx:Button id="bt1" x="167" y="88" label="保存"  click="sendSaveproductReq()"   width="80"  fontWeight="normal" fillAlphas="[1.0, 1.0]" fillColors="[#DDDCE2, #DDDCE2]" height="30" cornerRadius="2"/>
  139.         <mx:Button id="bt2" x="261" y="88" label="取消" click="cancleHandler();" width="80"  fontWeight="normal" fillAlphas="[1.0, 1.0]" fillColors="[#DDDCE2, #DDDCE2]" height="30" cornerRadius="2"/>
  140.     </mx:TitleWindow>
  141.     <mx:HTTPService showBusyCursor="true" url="/HttpServiceSlt" id="saveProductID"  
  142.         method="POST" resultFormat="text"  result="getProductSaveResult();"  >
  143.     </mx:HTTPService>
  144.     
  145.     <mx:HTTPService showBusyCursor="true" url="/HttpServiceSlt" id="productnameservice"  
  146.         method="POST" resultFormat="text"  result="reveiveProductNameRes();"  >
  147.     </mx:HTTPService>    
  148. </mx:Canvas>
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值