- <?xml version="1.0" encoding="utf-8"?>
- <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="215" height="760" backgroundColor="#A0AFB6">
- <mx:Script>
- <![CDATA[
- import code.ProductHandlerBasic;
- import mx.rpc.events.ResultEvent;
- import mx.events.DropdownEvent;
- import flash.display.*;
- import flash.net.URLRequest;
- import mx.controls.Image;
- import mx.core.Container;
- private var _productHandlerBase:ProductHandlerBasic ;
- private var pageCount:Number ;//页面总量
- [Bindable]
- private var pageNum:Number = 0;
- public function initAlbum():void{
- bookList.selectedIndex = 0 ;
- this.callLater(sendAlbumInfoRequest);
- }
- public function set productHandlerBase(p:ProductHandlerBasic):void{
- this._productHandlerBase = p ;
- }
- public function get productHandlerBase():ProductHandlerBasic{
- return this._productHandlerBase ;
- }
- /**============发送获取相册信息请求================================*/
- public function sendAlbumInfoRequest():void{
- var obj:Object = new Object() ;
- obj.random = Math.random() ;
- //obj.handlertype = 1;
- obj.methodName = "getAlbumXml" ;
- this.albumNameListId.send(obj);
- }
- /**===============获取相册名称列表================================*/
- public function getAlbumInfoResponse():void{
- var xml:XML = new XML(albumNameListId.lastResult);
- var xmllist:XMLList = xml.album ;
- var info:Array = new Array();
- for each(var n:XML in xmllist) {
- info.push({label:n.albumname ,data:n.albumid});
- }
- bookList.dataProvider = info ;
- bookList.addEventListener(DropdownEvent.CLOSE,chooseHandler)
- //=============默认打开第一个相册
- bookList.selectedIndex = 0 ;
- this.pageNum = 0 ;
- this.setPhotoNameRequest() ;
- }
- /**=============切换相册====================================*/
- public function chooseHandler(evt:DropdownEvent):void{
- this.pageNum =0 ;
- this.setPhotoNameRequest() ;
- }
- /**
- * 当前打开的相册
- */
- public function get albumID():String{
- return bookList.selectedItem.data ;
- }
- /**=============发送获取照片名称请求============================*/
- private function setPhotoNameRequest():void{
- var obj:Object = new Object() ;
- obj.random = Math.random() ;
- obj.methodName ="getPhotosXML" ;
- //obj.handlertype =2;
- obj.albumid = bookList.selectedItem.data ;
- obj.pageNum = this.pageNum ;
- photoNameListId.send(obj);
- }
- /**
- * ===================获取照片名称列表=====================/
- */
- public function getPhotoNameResponse():void{
- var xml:XML = new XML(photoNameListId.lastResult);
- var xmllist:XMLList = xml.photos ;
- //===================总片总数量
- this.pageCount = Number(xml.count.num);
- //this.pageNum = 0;
- this.pageNumTip();
- this.photolist.removeAllChildren();
- for each(var n:XML in xmllist) {
- var p:Image = new Image() ;
- p.source = n.abbrurl;
- p.id = n.id ;
- p.width =80 ;
- p.height = 60 ;
- p.buttonMode = true ;
- p.useHandCursor = true ;
- p.addEventListener(MouseEvent.CLICK,photoClickhandler);
- p.addEventListener(MouseEvent.MOUSE_OVER,mouserOverHandler) ;
- p.addEventListener(MouseEvent.MOUSE_OUT,mouserOutHandler) ;
- this.photolist.addChild(p);
- }
- //this._productHandlerBase.createProductContent();
- }
- /**
- * 单击相册照片
- * */
- private function photoClickhandler(e:MouseEvent):void{
- var s:String = Image(e.currentTarget).source.toString() ;
- s = s.replace("_2","_1") ;
- _productHandlerBase.albumPhotoClickHandler(s);
- }
- public function mouserOutHandler(e:MouseEvent):void{
- var i:Image = Image(e.currentTarget) ;
- i.alpha = 1 ;
- }
- public function mouserOverHandler(e:MouseEvent):void{
- var i:Image = Image(e.currentTarget) ;
- i.alpha = 0.5 ;
- }
- private function nextPage():void{
- this.pageNum++ ;
- //photobook.MAIN.tip_txt.text = "pagenum=="+this.pageNum+"=="+this.pageCount ;
- if(pageNum>=this.pageCount){
- this.pageNum = pageCount-1 ;
- return ;
- }
- setPhotoNameRequest() ;
- }
- private function prePage():void{
- this.pageNum-- ;
- if(this.pageNum<0){
- this.pageNum =0 ;
- return ;
- }
- setPhotoNameRequest() ;
- }
- /**====================分页信息显示栏==============================*/
- private function pageNumTip():void{
- pagenumShowid.text = ""+(this.pageNum+1)+"/"+this.pageCount;
- }
- ]]>
- </mx:Script>
- <mx:ComboBox id="bookList" x="10" y="92" width="195" fontSize="12"></mx:ComboBox>
- <mx:Tile width="197" id="photolist" height="604" backgroundAlpha="0.99" borderStyle="none" borderThickness="1" fontSize="3" borderColor="#B4B1AF" y="124" x="10">
- </mx:Tile>
- <mx:LinkButton label="上一页" x="22" y="730" fontWeight="normal" id="prepageID" click="prePage();" fontSize="12" textDecoration="normal" width="58.5" color="#FFFFFF"/>
- <mx:LinkButton x="137" y="730" label="下一页" fontWeight="normal" id="nextpageID" click="nextPage();" fontSize="12" textDecoration="normal" width="56" color="#FFFFFF"/>
- <!--
- <mx:HTTPService showBusyCursor="true" url="/PhotoBookServlet" id="albumNameListId" resultFormat="xml" result="getAlbumInfoResponse();" useProxy="false"/>
- <mx:HTTPService showBusyCursor="true" url="/PhotoBookServlet" id="photoNameListId" resultFormat="xml" result="getPhotoNameResponse();" useProxy="false"/>
- -->
- <mx:HTTPService showBusyCursor="true" url="/HttpServiceSlt" id="albumNameListId" resultFormat="xml" result="getAlbumInfoResponse();" useProxy="false"/>
- <mx:HTTPService showBusyCursor="true" url="/HttpServiceSlt" id="photoNameListId" resultFormat="xml" result="getPhotoNameResponse();" useProxy="false"/>
- <mx:Label id="pagenumShowid" width="41.5" height="18" x="87.5" y="734" color="#FFFFFF"/>
- </mx:Canvas>
flex 开发卡片相册处理(七)
最新推荐文章于 2024-04-27 12:46:54 发布