flex滑轮事件
发布时间:2020-12-15 01:23:16 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"? mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="500" height="500" backgroundColor="#0A7276" toolTip="鼠标滑轮滚动可以控制图片大小" showCloseButton="true" close="closeWi
<?xml version="1.0" encoding="utf-8"?> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="500" height="500" backgroundColor="#0A7276" toolTip="鼠标滑轮滚动可以控制图片大小" showCloseButton="true" close="closeWindow()" initialize="init()" borderColor="#0A7276" headerHeight="20" title="{imgname}" > <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.managers.PopUpManager; private function closeWindow():void{ mx.managers.PopUpManager.removePopUp(this); } [Bindable] private var source:String; [Bindable] private var imgname:String; private function init():void{ this.width=this.screen.width-300; this.height=this.screen.height-50; this.x=(this.screen.width-this.width)/2; this.y=(this.screen.height-this.height)/2; addEventListernerToImage(); } private function showSrcpage():void{ var u:URLRequest=new URLRequest(image.source.toString()); navigateToURL(u,'_blank'); } private function addEventListernerToImage():void{ this.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheelHandler); } private function mouseWheelHandler(event:MouseEvent):void{ resizeImageSize(event.delta);//deta为滑轮滚动时的刻度值 } private function resizeImageSize(size:int):void{ var w:int; var h:int; if(size>0){ w=image.width*(1+size/10); h=image.height*(1+size/10); }else if(size<0){ w=image.width/(1-size/10) h=image.height/(1-size/10) } if(image.width<50||image.height<50){ w=50; h=50*(image.height/image.width); }else if(image.width>=this.width||image.height>=this.height){ h=this.height-50; w=(h*image.width)/image.height; } image.width=w; image.height=h; } ]]> </mx:Script> <mx:VBox height="100%" width="100%"> <mx:HBox height="100%" width="100%"> <mx:Spacer width="50%"/> <mx:Image width="100%" height="100%" maxHeight="{this.height-40}" maxWidth="{this.width-50}" source="img/58.jpg" id="image" click="showSrcpage()" mouseChildren="false" buttonMode="true" useHandCursor="true" /> <mx:Spacer width="50%"/> </mx:HBox> </mx:VBox> </mx:TitleWindow> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |