




免费预览已结束,剩余10页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
!CDATAimport .navigateToURL;Bindableprivate var _imageURL:String = images/earth-map_small.jpg; private var _contextMenu:ContextMenu;private var _contextMenuItems:Array = Zoom In Image, Zoom Out Image, Show All Image, Toggle Smooth Bitmap, View Source;public function handleCreationComplete():void / handle contenxt menu_contextMenu = new ContextMenu();_contextMenu.hideBuiltInItems(); for (var i:uint = 0; iApplication backgroundGradientColors: #000000, #222222;Panel borderColor: #333333; headerHeight: 0;borderThicknessLeft: 4;borderThicknessRight: 4;borderThicknessTop: 4;borderThicknessBottom: 4;color: #999999;Button color: #000000;cornerRadius: 7;.ZoomInButton disabledSkin: Embed(source=icons/demoIcons.swf,symbol=MinusButton_Disabled);downSkin: Embed(source=icons/demoIcons.swf,symbol=MinusButton_Down);overSkin: Embed(source=icons/demoIcons.swf,symbol=MinusButton_Over);upSkin: Embed(source=icons/demoIcons.swf,symbol=MinusButton_Up);.ZoomOutButton disabledSkin: Embed(source=icons/demoIcons.swf,symbol=PlusButton_Disabled);downSkin: Embed(source=icons/demoIcons.swf,symbol=PlusButton_Down);overSkin: Embed(source=icons/demoIcons.swf,symbol=PlusButton_Over);upSkin: Embed(source=icons/demoIcons.swf,symbol=PlusButton_Up);Label color: #808080;CheckBox color: #808080;VBox borderStyle: solid;horizontalAlign: center; cornerRadius: 10; backgroundAlpha: 0.5; backgroundColor: #000000;borderThickness: 0; package com.adobe.wheelerstreet.fig.panzoomimport com.adobe.wheelerstreet.fig.panzoom.modes.PanZoomCommandMode;import com.adobe.wheelerstreet.fig.panzoom.utils.ContentRectangle;import flash.display.Bitmap;import flash.display.BlendMode;import flash.display.Loader;import flash.events.Event;import flash.events.IOErrorEvent;import flash.events.ProgressEvent;import flash.geom.Matrix;import flash.geom.Point;import flash.geom.Rectangle;import .URLRequest;import mx.controls.Label;import mx.controls.SWFLoader;import mx.core.UIComponent;import mx.effects.AnimateProperty;import mx.events.FlexEvent;import mx.events.ResizeEvent;import mx.events.TweenEvent;public class ImageViewer extends UIComponentBindablepublic var loadingImage:Boolean = false;Bindablepublic var bitmapScaleFactorMin:Number = .125;Bindablepublic var bitmapScaleFactorMax:Number = 5;private var _panZoomCommandMode:PanZoomCommandMode;public var viewRect:Rectangle;private var _contentRectangle:ContentRectangle;private var _bitmap:Bitmap;private var _bitmapScaleFactor:Number;private var _smoothBitmap:Boolean = false;private var _imageURL:String;private var _loader:Loader;private var _percentLoadedLabel:Label;/ preloader assetsEmbed(source=icons/iconography.swf, symbol=ProgressThrobber) private var _progressThrobber:Class;private var _progressSWF:SWFLoader;/ public getters/setters/* * Setting the imageURL triggers the loading of the image and extraction * and assignment of its bitmapData. */ Bindablepublic function get imageURL():Stringreturn _imageURL;public function set imageURL(value:String):void/ setting imageURL triggers loading sequenceif (value = _imageURL)return;_loader = new Loader(); _loader.load(new URLRequest(value);loadingImage = true; formatUI(); _percentLoadedLabel.text = ; invalidateDisplayList(); / load events _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handleLoadComplete);_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, handleLoadIOError);_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, handleLoadProgress);/* Setting the ImageViewers bitmap triggers the activation of the PanZoomCommandMode.* * The PanZoomCommandMode acts as the invoker element in the Command Pattern.* Its constructor requires that you assoiciate it with a client and a reciever. * In this implementation the client is the ImageView (this) and the * reciever is the bitmapData transform matrix. */public function get bitmap():Bitmapreturn _bitmap;public function set bitmap(value:Bitmap):voidif (value = _bitmap)return;_bitmap = value;_contentRectangle = new ContentRectangle(0,0,_bitmap.width, _bitmap.height, viewRect);/_contentRectangle.viewAll(viewRect);_panZoomCommandMode = new PanZoomCommandMode(this, _contentRectangle)_panZoomCommandMode.activate();invalidateDisplayList();/* Tracks the scale of the bitmap being displayed.* Setting the bitmapScale factor invalidates the displayList since any* change will requite an update.*/ Bindablepublic function get bitmapScaleFactor():Numberreturn _bitmapScaleFactor;public function set bitmapScaleFactor(value:Number):voidif (value = bitmapScaleFactor )return;if (value bitmapScaleFactorMax)return;_bitmapScaleFactor = value;invalidateDisplayList();/* * setting smoothBitmap to true hurts performance slightly */ Bindablepublic function get smoothBitmap():Booleanreturn _smoothBitmap;public function set smoothBitmap(value:Boolean):voidif (value = _smoothBitmap)return;_smoothBitmap = value;invalidateDisplayList();/ public functions/* * The zoom function requires a direction to be assigned when the function * is triggerd. in zooms in and conversly out zooms out. */public function zoom(direction:String):voidvar _animateProperty:AnimateProperty = new AnimateProperty(this);_animatePperty = bitmapScaleFactor;_animateProperty.addEventListener(TweenEvent.TWEEN_UPDATE, handleTween);_animateProperty.addEventListener(TweenEvent.TWEEN_END, handleTween);switch (direction)case in:if (_bitmapScaleFactor * 2 bitmapScaleFactorMax)_animateProperty.toValue = bitmapScaleFactorMax; else_animateProperty.toValue = _bitmapScaleFactor * 2;break;case out:if (_bitmapScaleFactor / 2 bitmapScaleFactorMax)_animateProperty.toValue = bitmapScaleFactorMax; else_animateProperty.toValue = _bitmapScaleFactor / 2;break;_animateProperty.play();function handleTween(e:TweenEvent):voidswitch (e.type)case tweenUpdate:_contentRectangle.zoom = bitmapScaleFactor;break;case tweenEnd:_contentRectangle.zoom = bitmapScaleFactor;_animateProperty.removeEventListener(TweenEvent.TWEEN_END, handleTween);_animateProperty.removeEventListener(TweenEvent.TWEEN_UPDATE, handleTween);break; /* * The zoomByOrigin function zooms in on the users current mouse position. * This function requires a direction to be assigned when the function * is triggerd. in zooms in and conversly out zooms out. */ public function zoomByOrigin(direction:String):voidvar _animateProperty:AnimateProperty = new AnimateProperty(_contentRectangle);_animatePperty = zoomByOrigin;_animateProperty.addEventListener(TweenEvent.TWEEN_UPDATE, handleTween);_animateProperty.addEventListener(TweenEvent.TWEEN_END, handleTween);_contentRectangle.zoomOrigin = new Point( (-_contentRectangle.x + mouseX) * 1/_contentRectangle.scaleX, (-_contentRectangle.y + mouseY) * 1/_contentRectangle.scaleY );switch (direction)case in:if (_bitmapScaleFactor * 2 bitmapScaleFactorMax)_animateProperty.toValue = bitmapScaleFactorMax; else_animateProperty.toValue = _bitmapScaleFactor * 2;break;case out:if (_bitmapScaleFactor / 2 bitmapScaleFactorMax)_animateProperty.toValue = bitmapScaleFactorMax; else_animateProperty.toValue = _bitmapScaleFactor / 2;break; _animateProperty.play();function handleTween(e:TweenEvent):voidswitch (e.type)case tweenUpdate:bitmapScaleFactor = e.valueas Number;break;case tweenEnd:_animateProperty.removeEventListener(TweenEvent.TWEEN_END, handleTween);_animateProperty.removeEventListener(TweenEvent.TWEEN_UPDATE, handleTween);break;public function setZoom(scale:Number):void_contentRectangle.zoom = scale;bitmapScaleFactor = scale;public function centerView():void_contentRectangle.viewAll(viewRect);bitmapScaleFactor = _contentRectangle.scaleX;/ constructor/ /* * Constructor. */ public function ImageViewer():voidviewRect = new Rectangle();_contentRectangle = new ContentRectangle(0,0,0,0,viewRect);addEventListener(ResizeEvent.RESIZE, handleResize);addEventListener(FlexEvent.CREATION_COMPLETE, handleCreationComplete);function handleCreationComplete(e:FlexEvent):void_contentRectangle.zoom = .5;bitmapScaleFactor = _contentRectangle.zoom;invalidateDisplayList(); /* * private */private function handleResize(e:ResizeEvent):voidif (_contentRectangle = null)return;_contentRectangle.centerToPoint(new Point(this.width/2, this.height/2);/ protected overrides/* * When the display list is updated the bitmap is drawn via a bitmapFill * applied to the UIComponents graphics layer. The size and position of the bitmap * are determined by the bitmapDatas transform matrix, which is derived by parsing * the _contentRectangles properties. * */ override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):voidsuper.updateDisplayList(unscaledWidth, unscaledHeight);viewRect.width = width;viewRect.height = height;if (_bitmap = null)/ if theres no bitmapData fill the component with blackgraphics.beginFill(0x000000,1)graphics.drawRect(0,0,unscaledWidth,unscaledHeight); else if (viewRect != null) var _bitmapTransform:Matrix = new Matrix(_contentRectangle.width / _bitmap.width, 0, 0, _contentRectangle.height / _bitmap.height, _contentRectangle.topLeft.x, _contentRectangle.topLeft.y );/ fill the component with the bitmap.graphics.clear()graphics.beginBitmapFill(_bitmap.bitmapData, / bitmapData _bitmapTransform, / matrix true, / tile? _smoothBitmap / smooth? ) graphics.drawRect(0,0,unscaledWidth, unscaledHeight);/ if the edge of the bitmap transition into view / we paint in the negative area.if (_contentRectangle.left viewRect.topLeft.x)graphics.beginFill(0x000000,1)graphics.drawRect(0,0, _contentRectangle.x, unscaledHeight);if (_contentRectangle.top viewRect.topLeft.y)graphics.beginFill(0x000000,1)graphics.drawRect(0,0,unscaledWidth, _contentRectangle.y);if (_contentRectangle.right viewRect.width)graphics.beginFill(0x000000,1)graphics.drawRect(_contentRectangle.right,0, viewRect.width - _contentRectangle.right , viewRect.height );if (_contentRectangle.bottom viewRect.height)graphics.beginFill(0x000000,1)graphics.drawRect(0,_contentRectangle.bottom, viewRect
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024版监控系统维保合同范本
- 2024版单位车辆出租协议
- 2025年事业单位工勤技能-河北-河北水文勘测工四级(中级工)历年参考题库含答案解析(5套)
- 2025年事业单位工勤技能-河北-河北工程测量工四级(中级工)历年参考题库含答案解析
- 2025年事业单位工勤技能-广西-广西家禽饲养员四级(中级工)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-广西-广西医技工一级(高级技师)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-广西-广西保健按摩师一级(高级技师)历年参考题库含答案解析
- 2025年事业单位工勤技能-广东-广东动物检疫员五级(初级工)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-广东-广东下水道养护工五级(初级工)历年参考题库典型考点含答案解析
- 2025年事业单位工勤技能-安徽-安徽机械冷加工一级(高级技师)历年参考题库典型考点含答案解析
- 诱思探究理论
- 浅析中国保险业发展现状
- 铣床日常点检保养记录表
- 农产品贮藏与加工教案
- 04某污水处理厂630kW柔性支架光伏发电项目建议书
- 2022中国移动通信集团重庆限公司招聘上岸笔试历年难、易错点考题附带参考答案与详解
- 北师大版九年级数学上九年级第一二单元综合数学试题
- 二级建造师成绩复核申请
- GB/T 25702-2010复摆颚式破碎机颚板磨耗
- GB 29541-2013热泵热水机(器)能效限定值及能效等级
- 住宅项目实测实量操作指引(图文并茂)
评论
0/150
提交评论