flex 開發卡片主類一

  1. package code
  2. {
  3.     /**
  4.      * 產品開發基本類
  5.      */
  6.     import flash.display.Bitmap;
  7.     import flash.display.BitmapData;
  8.     import flash.display.Loader;
  9.     import flash.events.Event;
  10.     import flash.events.MouseEvent;
  11.     import flash.geom.Matrix;
  12.     import flash.net.URLRequest;
  13.     
  14.     import module.TextEditview;
  15.     import module.photEditview;
  16.     
  17.     import mx.containers.Canvas;
  18.     import mx.controls.Image;
  19.     import mx.controls.TextArea;
  20.     import mx.core.Container;
  21.     import mx.managers.PopUpManager;
  22.     import mx.rpc.events.ResultEvent;
  23.     import mx.rpc.http.mxml.HTTPService;  
  24.     
  25.     public class ProductHandlerBasic extends Container
  26.     {
  27.         /*當前所編輯產品*/
  28.         private var _currentStage:Container ;
  29.         private var _productID:Number ;
  30.         /*所保存作品的ID,如果此產品沒保存過這爲-1*/
  31.         private var _recordID:Number=-1 ;  ; 
  32.         /*用戶選擇的模板圖片,在進入操作頁面之前,用戶需要選擇模板*/
  33.         private var _defaulModuleUrl:String  ;
  34.         
  35.         /*保存產品所以頁面的內容,例如模板,照片,文字。以xml到形式存放*/
  36.         private var _productDataContent:XML ;
  37.         
  38.         /*產品信息數據,每個型號所對應的價格,名稱等等*/
  39.         private var _productInfo:XML ;
  40.         
  41.         public var _testTextArea:TextArea ;
  42.          
  43.         /*當前主題的所有數據座標數據*/
  44.         private var _photoCoordinateData:XML ; 
  45.         
  46.         private var _httpservice:HTTPService ;
  47.         
  48.         /*照片在模板上的位置(順序)*/
  49.         private var _currentphotoNum:Number =0 ; ;
  50.         /*每一張的順序,如:上一張,下一張*/
  51.         private var _currentpageNum:Number =0 ;
  52.         /*當前頁面內容數據,由版式,照片文件組成*/
  53.         private var _currentpageData:XML ;
  54.         /*當前頁面的座標數據*/
  55.         private var _currentcoordinateData:XMLList ;
  56.         /*顯示模板,照片及一些操作*/
  57.         private var _userstage:Canvas ;
  58.         /*當前的模板圖片*/
  59.         private var _backgroundImage:Image= new Image() ;
  60.         /*產品innerNumber*/
  61.        
  62.         private var _productInnerNum:Number = 0 ;
  63.         public function ProductHandlerBasic()
  64.         {
  65.             _httpservice = new HTTPService();
  66.             _httpservice.showBusyCursor = true ; 
  67.             _httpservice.method = "post" ;
  68.             _httpservice.url = "/HttpServiceSlt";
  69.             _httpservice.resultFormat="xml";
  70.             _httpservice.addEventListener(ResultEvent.RESULT,createEditProudctContent);
  71.             
  72.             /*加入事件監聽,照片切換及照片編輯時,要用到此*/
  73.             _backgroundImage.addEventListener(MouseEvent.CLICK,photoClickHandler);
  74.             _backgroundImage.addEventListener(MouseEvent.DOUBLE_CLICK,photoDoubleClickHandler);
  75.             _backgroundImage.doubleClickEnabled = true ; 
  76.         }
  77.         /**
  78.          * 作品封面圖片地址
  79.          */
  80.         public function get previewURL():String{
  81.             return _productInfo.product.(@id==_productID).previewURL ;
  82.         }
  83.         /**
  84.          * 產品單價
  85.          */ 
  86.         public function get price():Number{
  87.             return _productInfo.product.(@id==_productID).price ;
  88.         }
  89.         /**
  90.          * 價格單位 
  91.          */ 
  92.         public function get unit():String{
  93.             return _productInfo.product.(@id==_productID).unit ;
  94.         }
  95.         /**
  96.          * 得到型號的總頁數
  97.          */ 
  98.         public function get pages():Number{ 
  99.             return _productInfo.product.(@id==_productID)..label.length();
  100.         }
  101.           
  102.         /**
  103.          * 增加郵票或信封的價格
  104.          */    
  105.         public function get stepPrice():Number{
  106.             return _productInfo.product.(@id==_productID)..stepprice;
  107.         }
  108.         /**
  109.          * 複合價格。例如加上信封和郵票的價格。
  110.          * 計算方法:基價+步價*innernumber
  111.          */ 
  112.         public function get duplexPrice():Number{
  113.              
  114.             return Math.round((this.productInnerNum*stepPrice+price)*100)/100 ;
  115.         } 
  116.         
  117.         /**
  118.          * 獲取型號下的主題信息.包括名稱,數量等等.
  119.          */    
  120.         public function get mbClass():XMLList{ 
  121.             return _productInfo.product.(@id==_productID)..subject;
  122.         }
  123.         
  124.         /**
  125.          * 型號。如:明星片,長賀卡
  126.          * 
  127.          */ 
  128.         public function get typename():String{
  129.             return _productInfo.product.(@id==_productID).file ;
  130.         }
  131.         
  132.         public function get productInnerNum():Number{
  133.               
  134.             return _productDataContent.innernumber;
  135.         }
  136.         public function set productInnerNum(p:Number):void{
  137.             _productDataContent.innernumber = p;
  138.         }
  139.         
  140.         /**
  141.          * 產品所屬類別
  142.          */ 
  143.         public function get classid():String{
  144.             return _productInfo.classid.@id ;
  145.         }
  146.         
  147.         public function set currentStage(c:Container):void{
  148.             this._currentStage = c ;
  149.         }
  150.         public function get currentStage():Container{
  151.             return this._currentStage ;
  152.         }
  153.         public function set productID(p:Number):void{
  154.             this._productID = p ;
  155.         }
  156.         public function get productID():Number{
  157.             return this._productID ;
  158.         }
  159.         public function set recordID(r:Number):void{
  160.             this._recordID= r ;
  161.         }
  162.         public function get recordID():Number{
  163.             return this._recordID ;
  164.         } 
  165.         public function set defaulModuleUrl(url:String):void{
  166.             this._defaulModuleUrl = url ;
  167.         }  
  168.         public function get defaulModuleUrl():String{
  169.             return this._defaulModuleUrl ;
  170.         }   
  171.         public function set productInfo(info:XML):void{
  172.             this._productInfo = info ;
  173.         }    
  174.         public function get productInfo():XML{
  175.             return this._productInfo ;
  176.         }   
  177.         public function set httpservice(h:HTTPService):void{
  178.             this._httpservice = h ;
  179.         }   
  180.         public function get httpservice():HTTPService{
  181.             return this._httpservice ;
  182.         }
  183.         public function set photoCoordinateData(p:XML):void{
  184.             this._photoCoordinateData = p ;
  185.         }
  186.         public function get photoCoordinateData():XML{
  187.             return this._photoCoordinateData ;
  188.         }
  189.         public function set userstage(s:Canvas):void{
  190.             this._userstage = s ;
  191.         }  
  192.         public function get userstage():Canvas{
  193.             return this._userstage ;
  194.         }
  195.         public function set currentpageNum(c:Number):void{
  196.             this._currentpageNum = c ;
  197.         }
  198.         public function get currentpageNum():Number{
  199.             return this._currentpageNum ;
  200.         } 
  201.         public function set currentphotoNum(p:Number):void{
  202.             this.currentphotoNum = p ;
  203.         } 
  204.         public function get currentphotoNum():Number{
  205.             return this._currentphotoNum ;
  206.         }
  207.         public function set productDataContent(p:XML):void{
  208.             this.productDataContent = p ;
  209.         } 
  210.         public function get productDataContent():XML{
  211.             return this._productDataContent ;
  212.         }
  213.         
  214.         /**
  215.          * 模板單擊處理,檢測鼠標的位置計算出,具體單擊的照片
  216.          */
  217.         private function photoClickHandler(e:MouseEvent):void{
  218.             var img :Image = null ;
  219.         
  220.             for(var i:int=0;i<this._currentcoordinateData.pic.length();i++){
  221.                 img =  this._userstage.getChildAt(i) as Image ;
  222.                 revertPhotoAlpha();
  223.                 if(img.hitTestPoint(mouseX,mouseY)){   
  224.                     this._currentphotoNum = i ;//當前照片的號碼
  225.                     img.alpha = 0.5 ;
  226.                     break ;
  227.                 }
  228.             }    
  229.         }
  230.         
  231.         /**
  232.          * 雙擊照片,彈出照片編輯窗口
  233.          */ 
  234.         private function photoDoubleClickHandler(e:MouseEvent):void{
  235.             var img_ :Image = null ;
  236.             for(var i:int=0;i<this._currentcoordinateData.pic.length();i++){
  237.                 img_ =  this._userstage.getChildAt(i) as Image ;
  238.                 revertPhotoAlpha();
  239.                 if(img_.hitTestPoint(mouseX,mouseY)){   
  240.                     this._currentphotoNum = i ;
  241.                     this.revertPhotoAlpha() ;
  242.                     var url_:String =     this._productDataContent.item[_currentpageNum]..img[i].@url ;
  243.                     var x_  :Number =     this._productDataContent.item[_currentpageNum]..img[i].@x ;
  244.                     var y_  :Number =     this._productDataContent.item[_currentpageNum]..img[i].@y ;
  245.                     var w_  :Number =     this._productDataContent.item[_currentpageNum]..img[i].@width ;
  246.                     var h_  :Number =     this._productDataContent.item[_currentpageNum]..img[i].@height ;
  247.                     
  248.                     /*照片編輯框*/
  249.                     var photoEdit_:photEditview = new photEditview();
  250.                     photoEdit_.producthandlerBase = this ;  
  251.                     PopUpManager.addPopUp(photoEdit_,this._currentStage,true);
  252.                     photoEdit_.initphotoEditParams(img_,url_,x_,y_,w_,h_);           
  253.                     break ;
  254.                 } 
  255.             }   
  256.         }
  257.         
  258.         /**
  259.          * 恢復照片透明度。用戶單擊照片,改變單擊的照片的透明度 ,以此來做標識 。
  260.          * 當用戶切換照片時,恢復照片透明度,再改變所選照片的透明度。
  261.          */ 
  262.         private function revertPhotoAlpha():void{
  263.             var img:Image = null ;
  264.             for(var i:int=0;i<this._currentcoordinateData.pic.length();i++){
  265.                 img =  this._userstage.getChildAt(i) as Image ;
  266.                 if(img.alpha==0.5){
  267.                     img.alpha = 1 ; 
  268.                     break ; 
  269.                 }    
  270.             }
  271.         }
  272.         /**
  273.          * 生成默認的產品內容,沒過型號都不相同,所以動態生成。
  274.          * 如果產品已經保存過的話,內容從服務端加載過來
  275.          */    
  276.         public function createProductContent():void{
  277.             if(this._recordID==-1){
  278.                 this.createNewProudctContent() ;    
  279.                 return ;            
  280.             }
  281.             //編輯產品
  282.             var params:Object = new Object() ;
  283.             params.methodName = "getProductContent" ;
  284.             params.random= Math.random() ; 
  285.             params.pid= this._recordID ; 
  286.             //this._testTextArea.text = "recordid=="+this._recordID ; 
  287.             this._httpservice.send(params) ;    
  288.         }   
  289.           
  290.         /*創建默認產品數據結構*/
  291.         private function createNewProudctContent():void{
  292.             _productDataContent = <wdxc></wdxc> ; 
  293.             /*得到此種型號的產品有多少頁數*/
  294.             var xmllist_t:XML = new XML(this._productInfo.product.(@id==_productID));       
  295.             var count:Number = xmllist_t.count ;
  296.   
  297.             for(var i:int=0;i<count;i++){ 
  298.                 /*每一張記錄節點*/
  299.                 var itemNode:XML  = <item></item>;
  300.                 var photoNode:XML =<photo></photo>;
  301.                 for(var j:int=0;j<13;j++){
  302.                     photoNode.appendChild(<img url="" x="-1" y="" width="" height=""/>);
  303.                 }  
  304.                   
  305.                 /*豪華摺疊卡沒辦法,這能這樣*/ 
  306.                 if(this._productID==598){               
  307.                     itemNode.appendChild(<bs>{_defaulModuleUrl.replace(".gif","_"+(i+1)+".gif")}</bs>);
  308.                 }else{
  309.                     itemNode.appendChild(<bs>{this._defaulModuleUrl}</bs>);
  310.                 }
  311.                 itemNode.appendChild(photoNode) ;  
  312.                 itemNode.appendChild(<txt><info></info></txt>);
  313.                 _productDataContent.appendChild(itemNode);      
  314.                  
  315.             }   
  316.             _productDataContent.appendChild(<innernumber>0</innernumber>);  
  317.             //創建是否需要郵票和信封組件
  318.             createOtherCom();
  319.             this.initCurrentPageInfoToStage(true);
  320.         }
  321.         /**如果產品已經保存,將從productRecord表中,加載數據。
  322.          * 而不是用訂單表中取得信息【編輯產品時】
  323.          */    
  324.         private function createEditProudctContent(e:ResultEvent):void
  325.             _productDataContent = new XML(e.result);
  326.             createOtherCom(); 
  327.             this.initCurrentPageInfoToStage(false);
  328.         }   
  329.         private var _defaultText:String = "單擊此處輸入文字" ;
  330.          
  331.         /**
  332.          * 初始化當前參數信息
  333.          * 1:加載模板圖片
  334.          * 2:加載對應的圖片
  335.          * @param recompute 
  336.          * 左邊是否重新計算
  337.          */
  338.         public function initCurrentPageInfoToStage(recompute:Boolean):void{
  339.                
  340.             this._currentphotoNum =  0 ;  
  341.             
  342.             /*得到當前頁的數據信息.*/      
  343.             _currentpageData = new XML(this._productDataContent.item[this._currentpageNum]) ;
  344.         
  345.             this._userstage.removeAllChildren();
  346.              
  347.             /*根據圖片在模板那的座標,生成容器,可單擊圖片而放入容器中*/
  348.             for(var i:int=0;i<getCurrentPhotoCount(_currentpageNum);i++){
  349.                 var img1_t:Image = new Image() ;
  350.                 this._userstage.addChild(img1_t);
  351.                 img1_t.name="img_"+i;
  352.                 
  353.                 img1_t.x = _currentcoordinateData.pic[i].@x ;
  354.                 img1_t.y = _currentcoordinateData.pic[i].@y ;
  355.                 img1_t.width = _currentcoordinateData.pic[i].@width ;
  356.                 img1_t.height = _currentcoordinateData.pic[i].@height ; 
  357.                 img1_t.scaleContent = true ;   
  358.                 
  359.                 /*加載圖片到模板相應的位置*/  
  360.                 this.loadphotoToStage(img1_t,i,recompute,_productDataContent.item[_currentpageNum].photo.img[i].@url);          
  361.   
  362.             }           
  363.             _backgroundImage.source = (this._productDataContent.item[this._currentpageNum].bs).toString(); 
  364.             this._userstage.addChild(_backgroundImage);  
  365.             /*加入用戶輸入的文字信息*/
  366.             for(var k:int=0;k<_currentcoordinateData.txt.length();k++){
  367.                 var textInfo_:TextArea = new TextArea() ;
  368.                 textInfo_.alpha = 0 ;
  369.                  
  370.                 textInfo_.setStyle("fontSize","12"); 
  371.                 textInfo_.name = "txt_"+k ;
  372.                 textInfo_.x = _currentcoordinateData.txt[k].@x ;
  373.                 textInfo_.y = _currentcoordinateData.txt[k].@y  ; 
  374.                 textInfo_.width= _currentcoordinateData.txt[k].@width ;
  375.                 textInfo_.height = _currentcoordinateData.txt[k].@height ;  
  376.                 textInfo_.editable = false ;
  377.                 if(_productDataContent.item[_currentpageNum].txt.info[k]==""||
  378.                     _productDataContent.item[_currentpageNum].txt.info[k]==null){
  379.                     textInfo_.text = _defaultText ;
  380.                 }else{
  381.                     textInfo_.htmlText = _productDataContent.item[_currentpageNum].txt.info[k] ;
  382.                 }  
  383.                   
  384.                 textInfo_.addEventListener(MouseEvent.CLICK,openTextEditview) ;
  385.                 this._userstage.addChild(textInfo_); 
  386.             }    
  387.         }
  388.         
  389.         /**
  390.          * 打開文字編輯窗口
  391.          * 
  392.          */ 
  393.         public function openTextEditview(e:MouseEvent):void{
  394.             var textInfo_:TextArea = TextArea(e.currentTarget);
  395.             var tev_ :TextEditview = new TextEditview() ;
  396.             PopUpManager.addPopUp(tev_,_currentStage,true,null);
  397.             tev_.targetLabelName = textInfo_.name ;
  398.             tev_.phander = this ;
  399.             var n_:Number = textInfo_.name.split("_")[1]; ;
  400.             
  401.             /*打開文字編輯窗口*/
  402.             tev_.my_rte.htmlText =_productDataContent.item[_currentpageNum].txt.info[n_] ;
  403.             tev_.my_rte.width = textInfo_.width ;
  404.             tev_.my_rte.height =textInfo_.height ;
  405.             tev_.my_rte.maxWidth = textInfo_.width ;
  406.             tev_.my_rte.maxHeight = textInfo_.height ;
  407.         
  408.             tev_.x = 100  ;  
  409.             tev_.y = 100  ; 
  410.         } 
  411.         /**
  412.         * 文字編輯完畢保存用戶輸入的文字 。
  413.         * 
  414.         */ 
  415.         
  416.         public function saveUserInputText(html_:String,txt_:String,labelname_:String):void{
  417.             
  418.             var lab_:TextArea = this._userstage.getChildByName(labelname_) as TextArea;
  419.              
  420.             if(txt_==null||txt_.length==0||txt_==""){
  421.                lab_.text= _defaultText ;
  422.            } else
  423.                 lab_.htmlText = html_ ;  
  424.                 var n_:Number = labelname_.split("_")[1]; ;
  425.                 _productDataContent.item[_currentpageNum].txt.info[n_] = html_ ;
  426.                 
  427.            }
  428.         }
  429.         
  430.         /**
  431.          * 當前模板最大能填充照片的張數。 自動填充照片時,需要用此 。
  432.          */ 
  433.         public function getCurrentPhotoCount(num_:Number):Number{
  434.             /*得到當前的模板名稱,通過此查詢其座標數據*/ 
  435.             var a1:Array = this._productDataContent.item[num_].bs.split("/"); 
  436.             var picname:String = a1[a1.length-1];
  437.             
  438.                        
  439.             /*得到當前的座標數據.例如:<pic x="98" y="10" width="112" height="111"/>*/
  440.             _currentcoordinateData=_photoCoordinateData.subject.mb.(@picname==picname);
  441.             
  442.             return  this._currentcoordinateData.pic.length();       
  443.         }
  444.         
  445.         /**
  446.          * 當前模板文字輸入框座標個數。
  447.          */ 
  448.         public function getCurrentTextCount(num_:Number):Number{
  449.             /*得到當前的模板名稱,通過此查詢其座標數據*/ 
  450.             var a1:Array = this._productDataContent.item[num_].bs.split("/"); 
  451.             var picname:String = a1[a1.length-1];
  452.             
  453.                        
  454.             /*得到當前的座標數據.例如:<pic x="98" y="10" width="112" height="111"/>*/
  455.             _currentcoordinateData=_photoCoordinateData.subject.mb.(@picname==picname);
  456.             
  457.             return  this._currentcoordinateData.txt.length();       
  458.         }
  459.         
  460.         /**
  461.          * 加載圖片到舞臺上,圖片顯示區域由模板框大小決定。模板的最大邊爲準。
  462.          * 用戶照片顯示區域的座標.照片編輯對照片裁剪的座標,首次沒有座標,則
  463.          * 取用戶圖片的中心位置如果用戶已經裁剪,則有座標,根據座標裁剪圖片。
  464.          * @param img:當前操作的圖片對象。相冊列表中所選擇的照片將在此顯示
  465.          * @param num:當前圖片在模板上的順序號碼。 
  466.          * @param recompute 座標是否需要重新計算。如:改變模板時,許重算 
  467.          * @param targerurl 用戶在相冊列表選擇的圖片地址。
  468.          * 
  469.         */    
  470.         public function loadphotoToStage(targetimg:Image,num:Number,recompute:Boolean,targerurl:String):void{
  471.             if(targerurl==null||targerurl==""){
  472.                 return ;
  473.             }           
  474.             /*把當前的所操作的圖片地址放入產品內容xml中*/   
  475.             //this._testTextArea.text ="url=="+targerurl+"targerurl.length"+targerurl.length;    
  476.             /*得到當前的對象的.以在匿名函數中使用*/       
  477.             var ph_t:ProductHandlerBasic = this ;
  478.             var loader_t:Loader = new Loader();   
  479.               
  480.             loader_t.contentLoaderInfo.addEventListener(Event.COMPLETE,function(e:Event):void{
  481.                 /*從產品內容數據中取得裁剪框在圖片上的座標*/
  482.                 var width1:Number=0 ;
  483.                 var height1:Number=0;
  484.                 var x1:Number =0 ; 
  485.                 var y1:Number =0 ; 
  486.                 x1 = ph_t._productDataContent.item[ph_t._currentpageNum]..img[num].@x ;
  487.                 y1 = ph_t._productDataContent.item[ph_t._currentpageNum]..img[num].@y ;
  488.                 width1 = ph_t._productDataContent.item[ph_t._currentpageNum]..img[num].@width ;
  489.                 height1 = ph_t._productDataContent.item[ph_t._currentpageNum]..img[num].@height ;
  490.                 /*圖片原始數據*/
  491.                 var oldbitmap_t:Bitmap = new Bitmap() ;
  492.                 var l:Loader = e.target.loader as Loader;  
  493.                 var oldbitmap_tdata:BitmapData = new  BitmapData (l.width,l.height) ;
  494.                 oldbitmap_tdata.draw(l); 
  495.                 /*是否需要重新計算座標*/
  496.                 if(recompute||x1==-1){ 
  497.                     /*計算出模板中圖片框的比例。根據此比例才能算出裁剪框的最大值*/
  498.                     var scale_t:Number =targetimg.width/targetimg.height ;
  499.                     /*根據比例求出高*/
  500.                     var h2:Number = l.width/scale_t ;                   
  501.                     if(h2<=l.height){
  502.                         height1 = h2 ; 
  503.                         width1 = l.width ;
  504.                     }else{    
  505.                         height1 = l.height ; 
  506.                         width1 = height1*scale_t ;
  507.                     }
  508.                      /*裁剪框在照片的座標*/
  509.                     x1 = (l.width-width1)/2 ; 
  510.                     y1 = (l.height-height1)/2;      
  511.                
  512.                     ph_t._productDataContent.item[ph_t._currentpageNum]..img[num].@x = x1 ;  
  513.                     ph_t._productDataContent.item[ph_t._currentpageNum]..img[num].@y = y1 ; 
  514.                     ph_t._productDataContent.item[ph_t._currentpageNum]..img[num].@width = width1 ;  
  515.                     ph_t._productDataContent.item[ph_t._currentpageNum]..img[num].@height =height1 ; 
  516.                     ph_t._productDataContent.item[ph_t._currentpageNum]..img[num].@url = targerurl ;
  517.                       
  518.                 } 
  519.                 /*存放從原始圖片數據裏裁剪出來的圖片數據*/
  520.                 var newbitmap_t:BitmapData  = new BitmapData(width1,height1);
  521.                 //座標轉化,把座標移到裁剪區域的位置,寬度和高度在cutbitmapdata裏指定。  
  522.                 var matrix:Matrix = new Matrix(1, 0, 0, 1, -x1, -y1);   
  523.                 newbitmap_t.draw(oldbitmap_tdata, matrix);    
  524.                 oldbitmap_t.bitmapData = newbitmap_t ;    
  525.                 targetimg.source = oldbitmap_t ; 
  526.    
  527.                 targetimg.scaleContent  = true ;
  528.                 ph_t._currentphotoNum++ ;
  529.                 }); 
  530.                 
  531.             loader_t.load(new URLRequest(targerurl)); 
  532.         } 
  533.         /**
  534.          * 更換模板,改變之後重新導入當前頁面信息
  535.          * 先改變內容數據,再重新加載
  536.          */ 
  537.         public function moduleChange(url:String):void{
  538.              
  539.             //豪華摺疊卡一次換3張
  540.             if(this.typename=="replicatecard"){
  541.                 
  542.                 this._productDataContent.item[0].bs = url.replace(".gif","_1.gif") ;
  543.                 this._productDataContent.item[1].bs = url.replace(".gif","_2.gif") ;
  544.                 this._productDataContent.item[2].bs = url.replace(".gif","_3.gif") ;                
  545.                 
  546.             } else{
  547.                 this._productDataContent.item[this._currentpageNum].bs = url ;
  548.             }
  549.             
  550.             initCurrentPageInfoToStage(true);
  551.         }
  552.         /**
  553.          * 單擊相冊照片,按順序填充照片到模板相應的位置 。
  554.          * @param url :被單擊照片url
  555.          */  
  556.         public function albumPhotoClickHandler(url:String):void{
  557.     
  558.             //======當前模板的圖片個數  
  559.             var t:Number = _currentcoordinateData.pic.length();
  560.            
  561.             if(this._currentphotoNum>t-1){
  562.                 this._currentphotoNum = 0 ;
  563.             }    
  564.              
  565.             
  566.             var img:Image = this._userstage.getChildByName("img_"+this._currentphotoNum) as Image ;
  567.             if(img==null){
  568.                 return ;
  569.             }
  570.             
  571.             this.loadphotoToStage(img,this._currentphotoNum,true,url);
  572.         }
  573.         /**
  574.          * 保存當前頁數據,如:圖片座標
  575.          * @param p1_  當前頁號碼
  576.          * @param p2_  當前照片號碼
  577.          * @param x_   起點座標 
  578.          * @param y    
  579.          * @param w_
  580.          * @param h_
  581.         
  582.          */   
  583.         public function saveCurrentPageData(p1_:Number,p2_:Number,url_:String,x_:Number,y_:Number,w_:Number,h_:Number):void{
  584.             _productDataContent.item[p1_]..img[p2_].@x =x_ ;    
  585.             _productDataContent.item[p1_]..img[p2_].@y =y_ ; 
  586.             _productDataContent.item[p1_]..img[p2_].@width =w_ ;
  587.             _productDataContent.item[p1_]..img[p2_].@height =h_ ;
  588.             _productDataContent.item[p1_]..img[p2_].@url=url_ ;
  589.                                         
  590.         } 
  591.         
  592.         
  593.         /**
  594.          * 創建其他額外的組件,此處初始化信封和郵件列表
  595.          */ 
  596.         public function createOtherCom():void{
  597.             //card.MAIN.right_id.sendAlbumInfoRequest();
  598.   
  599.             if(this.productInnerNum==1){
  600.                 
  601.                 card.MAIN.radbut1.selected = true ; 
  602.             }else{
  603.                 card.MAIN.radbut2.selected = true ;
  604.             } 
  605.             card.MAIN.header_id.recomputePrice();
  606.             card.MAIN.right_id.initAlbum();
  607.         }
  608.     }
  609. }
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章