Packageflare.vis.controls
Classpublic class PanZoomControl
InheritancePanZoomControl Inheritance Control Inheritance flash.events.EventDispatcher

Interactive control for panning and zooming a "camera". Any sprite can be treated as a camera onto its drawing content and display list children. The PanZoomControl allows you to manipulate a sprite's transformation matrix (the transform.matrix property) to simulate camera movements such as panning and zooming. To pan and zoom over a collection of objects, simply add a PanZoomControl for the sprite holding the collection.
  var s:Sprite; // a sprite holding a collection of items
  new PanZoomControl().attach(s); // attach pan and zoom controls to the sprite
  

Once a PanZoomControl has been created, panning is performed by clicking and dragging. Zooming is performed either by scrolling the mouse wheel or by clicking and dragging vertically while the control key is pressed.

By default, the PanZoomControl attaches itself to the stage to listen for mouse events. This works fine if there is only one collection of objects in the display list, but can cause trouble if you want to have multiple collections that can be separately panned and zoomed. The PanZoomControl constructor takes a second argument that specifies a "hit area", a shape in the display list that should be used to listen to the mouse events for panning and zooming. For example, this could be a background sprite behind the zoomable content, to which the "camera" sprite could be added. One can then set the scrollRect property to add clipping bounds to the panning and zooming region.



Public Properties
 PropertyDefined by
 Inheritedfilter : Function
Boolean function indicating the items considered by the control.
Control
  hitArea : InteractiveObject
The active hit area over which pan/zoom interactions can be performed.
PanZoomControl
 Inheritedobject : InteractiveObject
The interactive object this control is attached to.
Control
Public Methods
 MethodDefined by
  
PanZoomControl(hitArea:InteractiveObject = null)
Creates a new PanZoomControl.
PanZoomControl
  
attach(obj:InteractiveObject):void
Attach this control to the given interactive object.
PanZoomControl
  
detach():InteractiveObject
Detach this control.
PanZoomControl
Property detail
hitAreaproperty
hitArea:InteractiveObject  [read-write]

The active hit area over which pan/zoom interactions can be performed.

Implementation
    public function get hitArea():InteractiveObject
    public function set hitArea(value:InteractiveObject):void
Constructor detail
PanZoomControl()constructor
public function PanZoomControl(hitArea:InteractiveObject = null)

Creates a new PanZoomControl.

Parameters
hitArea:InteractiveObject (default = null) — a display object to use as the hit area for mouse events. For example, this could be a background region over which the panning and zooming should be done. If this argument is null, the stage will be used.
Method detail
attach()method
public override function attach(obj:InteractiveObject):void

Attach this control to the given interactive object. This method will automatically detach if already attached to another object.

Parameters
obj:InteractiveObject — the display object to attach to
detach()method 
public override function detach():InteractiveObject

Detach this control.

Returns
InteractiveObject — the interactive object this control was attached to, or null if this control was not attached.