- <?xml version="1.0" encoding="utf-8"?>
- <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="466" height="190" creationComplete="initUI();" alpha="1.0" borderColor="#F1F5F5" backgroundColor="#DFE8EE">
- <mx:Script>
- <![CDATA[
- import code.ProductHandlerBasic;
- import mx.formatters.DateFormatter;
- import mx.controls.Label;
- import mx.managers.PopUpManager;
- private var _recordid:Number ;
- private var _productContent:String ;
- private var _previewURL:String ;
- private var _productid:Number ;
- private var _phander:ProductHandlerBasic ;
- private function initUI():void{
- sendProductNameReq() ;
- }
- public function set productHanderBasic(p:ProductHandlerBasic):void{
- this._phander = p ;
- }
- public function get productHanderBasic():ProductHandlerBasic{
- return _phander ;
- }
- /**********保存产品***************************/
- private function sendSaveproductReq():void{
- if(productNameID.text==null||productNameID.text==""){
- return ;
- }
- bt1.label= "保存中...";
- //===保存当前输入的产品名称
- //photobook68.MAIN._productName = productNameID.text ;
- bt1.enabled = false ;
- var paras:Object = new Object();
- paras.methodName = "saveProductHanlder" ;
- paras.pid = _phander.recordID ;
- paras.productname = productNameID.text ;
- paras.randow = Math.random() ;
- paras.productid = _phander.productID ;
- paras.classid= _phander.classid ;
- paras.content = _phander.productDataContent.toXMLString() ;
- paras.previewURL = _phander.previewURL ;
- saveProductID.send(paras);
- }
- /*********保存产品,返回结果****************/
- private function getProductSaveResult():void{
- _phander.recordID = saveProductID.lastResult.toString() ;
- title1.removeAllChildren() ;
- var lb:Label = new Label() ;
- lb.x = 30;
- lb.y = 30 ;
- lb.text = "您的作品已经成功保存,可到/"我的相册->保存的礼物/"中查看。";
- lb.setStyle("fontSize","12");
- title1.addChild(lb) ;
- var bt:Button = new Button() ;
- bt.label = "确定";
- bt.width = 80 ;
- bt.setStyle("fontSize","12");
- bt.height = 30 ;
- bt.setStyle("cornerRadius","2");
- bt.setStyle("fontWeight","normal");
- bt.x=167 ;
- bt.y=88 ;
- bt.addEventListener(MouseEvent.CLICK,saveOk) ;
- this.title1.addChild(bt);
- var bt2:Button = new Button() ;
- bt2.label = "查看作品";
- bt2.width = 80 ;
- bt2.setStyle("fontSize","12");
- bt2.setStyle("fontWeight","normal");
- bt.setStyle("cornerRadius","2");
- bt2.x=261 ;
- bt2.y=88 ;
- bt2.height = 30 ;
- bt2.addEventListener(MouseEvent.CLICK,viewProduct) ;
- this.title1.addChild(bt2);
- }
- /**==============成功保存作品====================**/
- private function saveOk(e:MouseEvent):void{
- //photobook68.MAIN.deleteAlphaBackground();
- this.removeEventListener(MouseEvent.CLICK,saveOk);
- this.removeEventListener(MouseEvent.CLICK,viewProduct);
- // this.parent.removeChild(this) ;
- PopUpManager.removePopUp(this) ;
- }
- /**==============查看作品====================**/
- private function viewProduct(e:MouseEvent):void{
- var url:String = "/pages/product/newPhotoBook/productrecord_index.faces" ;
- var request:URLRequest = new URLRequest(url);
- navigateToURL(request,"_self");
- }
- /*********取消保存****************/
- private function cancleHandler():void{
- //photobook68.MAIN.deleteAlphaBackground();
- //this.parent.removeChild(this) ;
- PopUpManager.removePopUp(this);
- }
- /*********请求获取产品名称****************/
- private function sendProductNameReq():void{
- //=========第一次做产品,还没有产品名称
- if(_phander.recordID==-1){
- var f:DateFormatter = new DateFormatter() ;
- f.formatString = "YYYYMMDD" ;
- this.productNameID.text = "我的个性卡片"+f.format(new Date());
- }else{
- //=========编辑产品时
- var obj:Object = new Object() ;
- obj.methodName = "getProductName";
- obj.randow = Math.random() ;
- obj.pid = _phander.recordID ;
- productnameservice.send(obj) ;
- }
- }
- /*********取得已经保存产品的名称****************/
- private function reveiveProductNameRes():void{
- this.productNameID.text = productnameservice.lastResult.toString() ;
- }
- ]]>
- </mx:Script>
- <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">
- <mx:Label x="10" id="id1" y="29" width="122" text="输入您的作品名称:" fontWeight="bold" fontFamily="Courier New" color="#6C6868"/>
- <mx:TextInput x="151" y="29" borderStyle="solid" borderThickness="2" height="22" width="188" id="productNameID" />
- <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"/>
- <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"/>
- </mx:TitleWindow>
- <mx:HTTPService showBusyCursor="true" url="/HttpServiceSlt" id="saveProductID"
- method="POST" resultFormat="text" result="getProductSaveResult();" >
- </mx:HTTPService>
- <mx:HTTPService showBusyCursor="true" url="/HttpServiceSlt" id="productnameservice"
- method="POST" resultFormat="text" result="reveiveProductNameRes();" >
- </mx:HTTPService>
- </mx:Canvas>
flex 开发卡片保存产品(四)
最新推荐文章于 2024-09-11 22:10:32 发布