Flex Store sample application - Flex Interface Guide (FIG): The Pan|Zoom component

User level

Intermediate

Most of the standard Flex data controls display content sequentially, as does the List component, or as a table, as does DataGrid component. ThePan|Zoom component displays content spatially, as a two-dimensional surface that users can navigate around or zoom in and out to view the content. ThePan|Zoom component allows you to display spatial content types that the standard Flex controls don’t support well, such as maps and large images and diagrams.

Demo: The Pan|Zoom component. Note that this component is still in beta. Feel free to use it however you wish, but keep in mind that parts may contain bugs. Give us feedback on theFlex Interface Guide Forum.

To download and view the full source, right-click the Flex application and select View Source from the context menu. Otherwise, you can use the download link below.

Download the code

Note: This component is licensed as Sample Code as defined in theFlex End User License Agreement. You may use the sample code in your products, commercial or not.

Component guidelines

  • Use the Pan|Zoom control to allow users to navigate within large amounts of spatially organized data.
  • Use the Pan|Zoom control when users will mostly want to focus on a subset of the spatial information.
  • Combine the Pan|Zoom control with the Callout control to show important details in place on the spatial surface.
  • Do not use the Pan|Zoom control when users will want to see the content all at once. Instead, simply render the content as an Image.
  • Use the slider and zoom in/zoom out buttons to allow users to alter the zoom level.
  • Always use the hand cursor when the user is panning.

Component features

The features of the component are as follows:

  • Panning using drag-and-drop.
  • Clicking the image re-centers the content within the view.
  • Double-clicking the image re-centers the view of the image and zooms in on the content.
  • Shift-double-clicking the image re-centers the view and zooms out on the content.
  • Dragging past the edge of the image is prevented. The content returns to position after the user releases the mouse.
    How to use the component

The Pan|Zoom component functionality is built around a Command Design Pattern. The Command Design Pattern classically consists of five elements.

  • Command Interface (ICommand.as)
  • Concrete Command (PanMouseCommand.as, ZoomCommand.as, and so forth)
  • A Reciever (any UIComponent; a map for this example)
  • A Client (PanZoomContainer.as)
  • An Invoker (PanZoomCommandMode.as)

The Command Design Pattern encapsulates functionality into a Command Class. The Commands are then driven from the Client to the Receiver through an Invoker class. This decoupling of the Client from the Receiver allows for a range of features that would be difficult to implement otherwise and offers flexibility in development.

The Pan|Zoom component implementation differs slightly in that the Invoker class implements an ICommandMode interface. While not used in this example, this interface allows the developer to activate or deactivate thePan|Zoom component controls as a whole, which would be necessary in any real-world usage.

This content is a public draft. Please give us feedback in the Flex Interface Guide Forum.

Comments (3)

  • Hi everyone,
      
    I added a little fix to keep the bitmap in sight, when zooming out.  
    Where 700 and 423 is my ImageViewer width & height.
      
    public function zoom(direction:String):void
       {
        zoomDirection = direction;
        
        var _animateProperty:AnimateProperty = new AnimateProperty(this);  
        _animateProperty.property = "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):void
        {    
         switch (e.type)
         {
          case "tweenUpdate":
           skipUpdateEvent = true;
            
           _contentRectangle.zoom = bitmapScaleFactor;        
            
           // adjust x & y so the map stays centered        
           // left edge
           if(_contentRectangle.x > 0 ){
            _contentRectangle.x = 0;
           }      
           // top
           if(_contentRectangle.y > 0){
            _contentRectangle.y = 0;
           }
           // right edge
           if(_contentRectangle.x + _bitmap.width*bitmapScaleFactor < 700){
            _contentRectangle.x = 0 - _bitmap.width*bitmapScaleFactor + 700;
           }      
           // bottom
           if(_contentRectangle.y + _bitmap.height*bitmapScaleFactor < 423){
            _contentRectangle.y = 0 - _bitmap.height*bitmapScaleFactor + 423;
           }        
            
           break;
          
          case "tweenEnd":
           skipUpdateEvent = false;
           _contentRectangle.zoom = bitmapScaleFactor;  
           _animateProperty.removeEventListener(TweenEvent.TWEEN_END, handleTween);  
           _animateProperty.removeEventListener(TweenEvent.TWEEN_UPDATE, handleTween);
           break;
         }
        }      
                        
       }

  • If you're looking for a pan zoom component supporting panning containers and other Flex content besides bitmaps, check outhttp://www.rockholla.org/technology/2011/01/07/flex-as3-pan-zoom-component

  • The right click view source is broken, but the .zip download is OK.

Please sign in to improve or rate the content.
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
『软件说明』 —————————————————— 软件名称:ZoomIt v4.0.0.0 软件类别:微软放大镜 运行环境:Win2003, WinXp, Win2000, Win9x 授权方式:免费 软件介绍: ZoomIt(主页|介绍)是一款非常实用的投影演示辅助工具。它源自Sysinternals公司,后来此公司被微软收购,因此,有些网友也称 ZoomIt为微软放大镜。ZoomIt只有一个exe文件(0.5MB)、完全免费、易于使用。通过快捷键可以很方便地调用ZoomIt三项功能: 屏幕放大、屏幕注释、定时提醒。 附:软件更新情况 ZoomIt v4(2009-08-05):   修复bug;改善 Vista 和 Windows 7 下实时放大(live zoom)的性能。 ZoomIt v3.01:   增加 LiveZoom 模式,适用于Windows Vista 及更高版本;可自定义打字、计时字体(仍不支持中文);放大后的屏幕可以Ctrl+C复制到剪贴板。 ZoomIt v2.2 更新内容:   1、屏幕绘图时如果光标过小,则显示为十字形,以便看清   2、输入文字时可以用鼠标移动插入文字的位置 ZoomIt v2.11版更新内容:   1、可以改变倒计时文字的颜色   2、改变了截屏方式,可以包含工具提示 『汉化说明』 ———————————————————————— 此程序是由Borland Delphi 2.0 +Microsoft Visual Studio C++6.0编写,本人对Delphi不熟悉,所以点击托盘出现的英文没有汉化, 汉化不是很完美,但绝对满足你的使用,请大家多多包涵。 Gemgin 现在是一名软件工程师,收入来源用于自身疾病治疗,十分需要您的支持,如果您想支持 Gemgin 的话,请捐助 Gemgin 吧! 捐助地址: 暂时为空。 『Gemgin 说明』 ———————————————————————— 此汉化由Gemgin制作。原程序版权归其制作人所有,本汉化版权归Gemgin所有。 Gemgin汉化软件纯粹是为方便国人,没有任何商业目的。使用此汉化给您造成的任何损失,请自行承担! 此汉化可任意下载、拷贝、传播,但Gemgin不承担因此而产生的所有可能的责任。 若传播、拷贝、转发请保正原汉化包的完整,请不要删改任何文件。 未经本人允许,请勿将此汉化用于商业用途和一切与“钱”有关的任何行为,因此而产生的所有不良后果与Gemgin无关,由使用者自行承担责任。 本人水平有限,难免会有错误,如有发现,希望能够通知我一声,多谢。 『关于 Gemgin』 ———————————————————— QQ:308463776 E-mail: [email protected] BLOG: http://hexun.com/ctfysj By Gemgin 2009.09/17 广东◎深圳

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

帆软爱好者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值