├── .gitignore ├── flex-object-handles-2 ├── .actionScriptProperties ├── .flexProperties ├── .project ├── README ├── deploy │ ├── README │ ├── ant-googlecode.jar │ ├── build.xml │ ├── commons-net-1.4.1.jar │ ├── swcconfig-flex4.xml │ ├── swcconfig.xml │ └── version.properties ├── libs │ └── DegrafaOrigin.swc └── src │ ├── ObjectHandles2Example.mxml │ ├── ObjectHandlesFlex4Example.mxml │ └── com │ └── roguedevelopment │ └── objecthandles │ ├── CircleHandle.as │ ├── DragGeometry.as │ ├── Flex3ChildManager.as │ ├── Flex4ChildManager.as │ ├── Flex4HandleFactory.as │ ├── HandleClickedEvent.as │ ├── HandleDefinitions.as │ ├── HandleDescription.as │ ├── HandleRoles.as │ ├── IChildManager.as │ ├── IConstraint.as │ ├── IHandle.as │ ├── IMoveable.as │ ├── IResizeable.as │ ├── ObjectChangedEvent.as │ ├── ObjectHandles.as │ ├── ObjectHandlesSelectionManager.as │ ├── SelectionEvent.as │ ├── SpriteHandle.as │ ├── VisualElementHandle.as │ ├── constraints │ ├── MaintainProportionConstraint.as │ ├── MovementConstraint.as │ └── SizeConstraint.as │ ├── decorators │ ├── AlignmentDecorator.as │ ├── DecoratorManager.as │ ├── IDecorator.as │ ├── OutlineDecorator.as │ └── WebDecorator.as │ └── example │ ├── DegrafaHandle.mxml │ ├── Example1.mxml │ ├── Example2.mxml │ ├── Example3.mxml │ ├── Example4.mxml │ ├── Example5.mxml │ ├── Example6.mxml │ ├── Example7.mxml │ ├── Example8.mxml │ ├── Flex4Example1.mxml │ ├── MoveableTextArea.as │ ├── SimpleDataModel.as │ ├── SimpleFlex4Shape.mxml │ ├── SimpleFlexShape.as │ ├── SimpleSpriteShape.as │ └── TextDataModel.as └── flex-object-handles ├── .actionScriptProperties ├── .flexProperties ├── .project ├── .settings └── org.eclipse.core.resources.prefs └── src ├── MoveAndResize.mxml ├── assets └── cursors │ ├── blue │ ├── AppStarting.png │ ├── Arrow.png │ ├── Cross.png │ ├── Hand.png │ ├── Handwriting.png │ ├── Help.png │ ├── IBeam.png │ ├── Link.png │ ├── NO.png │ ├── SizeAll.png │ ├── SizeNESW.png │ ├── SizeNS.png │ ├── SizeNWSE.png │ ├── SizeWE.png │ ├── UpArrow.png │ └── Wait.png │ ├── cursor │ ├── horizontalSize.gif │ ├── leftObliqueSize.gif │ ├── mouseMove.gif │ ├── rightObliqueSize.gif │ └── verticalSize.gif │ ├── light │ ├── AppStarting.png │ ├── Arrow.png │ ├── Cross.png │ ├── Hand.png │ ├── Handwriting.png │ ├── Help.png │ ├── IBeam.png │ ├── Link.png │ ├── NO.png │ ├── SizeAll.png │ ├── SizeNESW.png │ ├── SizeNS.png │ ├── SizeNWSE.png │ ├── SizeWE.png │ ├── UpArrow.png │ └── Wait.png │ ├── set1 │ ├── pointer.png │ ├── resize-h.png │ ├── resize-l.png │ ├── resize-r.png │ └── resize-v.png │ ├── set2 │ ├── move.png │ ├── pointer.png │ ├── resize-h.png │ ├── resize-l.png │ ├── resize-r.png │ └── resize-v.png │ └── set3 │ ├── move.png │ ├── pointer.png │ ├── resize-h.png │ ├── resize-l.png │ ├── resize-r.png │ └── resize-v.png ├── com └── roguedevelopment │ ├── objecthandles │ ├── FixedRatioObjectHandles.as │ ├── Handle.as │ ├── ImageHandle.as │ ├── MouseCursorDetails.as │ ├── OHMouseCursors.as │ ├── ObjectHandleEvent.as │ ├── ObjectHandles.as │ ├── ObjectHandlesCanvas.as │ ├── ObjectHandlesMouseCursors.as │ ├── ObjectHandlesMouseCursors2.as │ ├── Selectable.as │ ├── SelectionManager.as │ ├── SizeAll.png │ ├── SizeNESW.png │ ├── SizeNS.png │ ├── SizeNWSE.png │ ├── SizeWE.png │ ├── resizeHandle.png │ ├── resizeHandle.psd │ ├── rotateHandle.png │ └── rotateHandle.psd │ └── popupbar │ └── PopupBar.as ├── resize_handle.png ├── rotate_handle.png └── snowflake.png /.gitignore: -------------------------------------------------------------------------------- 1 | deploy 2 | html-template 3 | bin-debug 4 | bin-release -------------------------------------------------------------------------------- /flex-object-handles-2/.actionScriptProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /flex-object-handles-2/.flexProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /flex-object-handles-2/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | FlexObjectHandles2 4 | 5 | 6 | 7 | 8 | 9 | com.adobe.flexbuilder.project.flexbuilder 10 | 11 | 12 | 13 | 14 | 15 | com.adobe.flexbuilder.project.flexnature 16 | com.adobe.flexbuilder.project.actionscriptnature 17 | 18 | 19 | -------------------------------------------------------------------------------- /flex-object-handles-2/README: -------------------------------------------------------------------------------- 1 | ***** VERSION 2 2 | 3 | This is a Version 2 release of ObjectHandles. It was a rewrite from scratch with a completely different API. If 4 | you're upgrading from a 1.0 release, you may want to look for a download with a "1.0" version number such as: 5 | ObjectHandles-1.0.0015-src.zip 6 | 7 | Most of the examples and instructions on the website are still targetting version 1 8 | 9 | ***** SWCs 10 | 11 | The easiest way to get started is to grab the appropriate .swc from the the deploy folder, copy that to the 12 | libs folder of your project, and start using the classes. 13 | 14 | ***** Examples 15 | 16 | Examples can be found in 17 | ObjectHandles2Example.mxml (A comprehensive set of examples) 18 | ObjectHandlesFlex4Example.mxml (A specialized example showing how to use ObjectHandles in Flex 4) 19 | Other example classes are in: com.roguedevelopment.objecthandles.examples 20 | 21 | ***** SUPPORT 22 | 23 | For support, please see the google group at: http://groups.google.com/group/objecthandles 24 | 25 | The group is the best place for support! 26 | 27 | ***** Using Object Handles? 28 | Please tell us about projects using ObjectHandles, we love to see them. We'd love to list it on our usage page 29 | http://code.google.com/p/flex-object-handles/wiki/ObjectHandlesUsage 30 | 31 | We've had over 75,000 downloads, but only know about a half dozen projects using ObjectHandles. Please consider letting us 32 | know about yours, it really helps to keep us motivated. 33 | 34 | ***** DOWNLOADS 35 | 36 | The latest version of this project can always be downloaded from: http://code.google.com/p/flex-object-handles/downloads/list 37 | 38 | 39 | ***** LICENSE 40 | 41 | * 42 | * Copyright (c) 2009 Marc Hughes 43 | * 44 | * Permission is hereby granted, free of charge, to any person obtaining a 45 | * copy of this software and associated documentation files (the "Software"), 46 | * to deal in the Software without restriction, including without limitation 47 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 48 | * and/or sell copies of the Software, and to permit persons to whom the Software 49 | * is furnished to do so, subject to the following conditions: 50 | * 51 | * The above copyright notice and this permission notice shall be included in all 52 | * copies or substantial portions of the Software. 53 | * 54 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 55 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 56 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 57 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 58 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 59 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 60 | * 61 | * ------------------------------------------------------------------------------------------- 62 | * 63 | * Contributions by: 64 | * 65 | * Alexander Kludt 66 | * Thomas Jakobi 67 | * Mario Ernst 68 | * Aaron Winkler 69 | * Gregory Tappero 70 | * Andrew Westberg 71 | * 72 | 73 | 74 | 75 | ****** OTHER SOFTWARE 76 | 77 | For one of our examples, we use the Degrafa library which is also licensed under the MIT license. You can 78 | read more about that here: http://degrafa.org/ 79 | 80 | We include the Degrafa library in our libs folder to make building the example easier. You don't not need to 81 | include this in your project unless you plan on using Degrafa as well. 82 | 83 | 84 | -------------------------------------------------------------------------------- /flex-object-handles-2/deploy/README: -------------------------------------------------------------------------------- 1 | 2 | 3 | In this folder you'll find prebuilt swcs for both Flex 3 and Flex 4, if you're just using ObjectHandles in a project, 4 | you can probably just plop one of those in your libs folder. 5 | 6 | The other files are neccessary to build a swc with ant, create an archive of the source, and upload it all to google code. You 7 | probably won't need those. 8 | -------------------------------------------------------------------------------- /flex-object-handles-2/deploy/ant-googlecode.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles-2/deploy/ant-googlecode.jar -------------------------------------------------------------------------------- /flex-object-handles-2/deploy/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /flex-object-handles-2/deploy/commons-net-1.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles-2/deploy/commons-net-1.4.1.jar -------------------------------------------------------------------------------- /flex-object-handles-2/deploy/swcconfig-flex4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ../src 5 | 6 | 7 | 8 | ObjectHandles.swc 9 | 10 | com.roguedevelopment.objecthandles.CircleHandle 11 | com.roguedevelopment.objecthandles.DragGeometry 12 | com.roguedevelopment.objecthandles.SpriteHandle 13 | com.roguedevelopment.objecthandles.VisualElementHandle 14 | com.roguedevelopment.objecthandles.HandleDefinitions 15 | com.roguedevelopment.objecthandles.HandleDescription 16 | com.roguedevelopment.objecthandles.HandleRoles 17 | com.roguedevelopment.objecthandles.IConstraint 18 | com.roguedevelopment.objecthandles.IHandle 19 | com.roguedevelopment.objecthandles.IMoveable 20 | com.roguedevelopment.objecthandles.IResizeable 21 | com.roguedevelopment.objecthandles.ObjectChangedEvent 22 | com.roguedevelopment.objecthandles.ObjectHandles 23 | com.roguedevelopment.objecthandles.ObjectHandlesSelectionManager 24 | com.roguedevelopment.objecthandles.SelectionEvent 25 | com.roguedevelopment.objecthandles.constraints.MaintainProportionConstraint 26 | com.roguedevelopment.objecthandles.constraints.MovementConstraint 27 | com.roguedevelopment.objecthandles.constraints.SizeConstraint 28 | com.roguedevelopment.objecthandles.Flex3ChildManager 29 | com.roguedevelopment.objecthandles.Flex4ChildManager 30 | com.roguedevelopment.objecthandles.Flex4HandleFactory 31 | com.roguedevelopment.objecthandles.decorators.DecoratorManager 32 | com.roguedevelopment.objecthandles.decorators.AlignmentDecorator 33 | com.roguedevelopment.objecthandles.decorators.WebDecorator 34 | com.roguedevelopment.objecthandles.decorators.OutlineDecorator 35 | 36 | 37 | -------------------------------------------------------------------------------- /flex-object-handles-2/deploy/swcconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ../src 5 | 6 | 7 | ObjectHandles.swc 8 | 9 | com.roguedevelopment.objecthandles.CircleHandle 10 | com.roguedevelopment.objecthandles.DragGeometry 11 | com.roguedevelopment.objecthandles.SpriteHandle 12 | com.roguedevelopment.objecthandles.HandleDefinitions 13 | com.roguedevelopment.objecthandles.HandleDescription 14 | com.roguedevelopment.objecthandles.HandleRoles 15 | com.roguedevelopment.objecthandles.IConstraint 16 | com.roguedevelopment.objecthandles.IHandle 17 | com.roguedevelopment.objecthandles.IMoveable 18 | com.roguedevelopment.objecthandles.IResizeable 19 | com.roguedevelopment.objecthandles.ObjectChangedEvent 20 | com.roguedevelopment.objecthandles.ObjectHandles 21 | com.roguedevelopment.objecthandles.ObjectHandlesSelectionManager 22 | com.roguedevelopment.objecthandles.SelectionEvent 23 | com.roguedevelopment.objecthandles.constraints.MaintainProportionConstraint 24 | com.roguedevelopment.objecthandles.constraints.MovementConstraint 25 | com.roguedevelopment.objecthandles.constraints.SizeConstraint 26 | com.roguedevelopment.objecthandles.Flex3ChildManager 27 | com.roguedevelopment.objecthandles.decorators.DecoratorManager 28 | com.roguedevelopment.objecthandles.decorators.AlignmentDecorator 29 | com.roguedevelopment.objecthandles.decorators.WebDecorator 30 | com.roguedevelopment.objecthandles.decorators.OutlineDecorator 31 | 32 | -------------------------------------------------------------------------------- /flex-object-handles-2/deploy/version.properties: -------------------------------------------------------------------------------- 1 | #Sat Apr 03 14:36:29 EDT 2010 2 | oh.build.num=0009 3 | -------------------------------------------------------------------------------- /flex-object-handles-2/libs/DegrafaOrigin.swc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles-2/libs/DegrafaOrigin.swc -------------------------------------------------------------------------------- /flex-object-handles-2/src/ObjectHandles2Example.mxml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/ObjectHandlesFlex4Example.mxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 16 | 17 | 18 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/CircleHandle.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import com.roguedevelopment.objecthandles.SpriteHandle; 4 | 5 | /** 6 | * A simple circle based handle instead of the square one. This is more of an example 7 | * on how to do alterntative handles. 8 | **/ 9 | public class CircleHandle extends SpriteHandle 10 | { 11 | public function CircleHandle() 12 | { 13 | super(); 14 | } 15 | 16 | override public function redraw():void 17 | { 18 | graphics.clear(); 19 | if( isOver ) 20 | { 21 | graphics.lineStyle(1,0x3dff40); 22 | graphics.beginFill(0xc5ffc0 ,1); 23 | } 24 | else 25 | { 26 | graphics.lineStyle(1,0); 27 | graphics.beginFill(0x51ffee,1); 28 | } 29 | 30 | graphics.drawCircle(0,0,6); 31 | graphics.endFill(); 32 | } 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/DragGeometry.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | package com.roguedevelopment.objecthandles 27 | { 28 | import flash.geom.Rectangle; 29 | 30 | /** 31 | * Internally, ObjectHandles uses a DragGeometry to keep track of component during active 32 | * moves, and is how it applies constraints to those moves. 33 | **/ 34 | public class DragGeometry 35 | { 36 | [Bindable] public var x:Number=0; 37 | [Bindable] public var y:Number=0; 38 | [Bindable] public var width:Number=0; 39 | [Bindable] public var height:Number=0; 40 | [Bindable] public var rotation:Number=0; 41 | [Bindable] public var isLocked:Boolean = false; 42 | 43 | public function clone() : DragGeometry 44 | { 45 | var rv:DragGeometry = new DragGeometry(); 46 | rv.x = x; 47 | rv.y = y; 48 | rv.width = width; 49 | rv.height = height; 50 | rv.rotation = rotation; 51 | return rv; 52 | } 53 | 54 | public function copyFrom( other:DragGeometry ) : void 55 | { 56 | x=other.x; 57 | y=other.y; 58 | width=other.width; 59 | height=other.height; 60 | rotation=other.rotation; 61 | } 62 | 63 | 64 | public function getRectangle() : Rectangle 65 | { 66 | return new Rectangle(x,y,width,height); 67 | } 68 | 69 | public function toString() : String 70 | { 71 | return "[DragGeometry " + x + "," + y + "+" + width + "x" + height + "]"; 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/Flex3ChildManager.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import flash.display.DisplayObject; 4 | 5 | import mx.core.Container; 6 | 7 | /** 8 | * A class that knows how to add and remove children from a Flex 3 based component using 9 | * either addChild or rawChildren.addChild 10 | **/ 11 | public class Flex3ChildManager implements IChildManager 12 | { 13 | public function Flex3ChildManager() 14 | { 15 | } 16 | 17 | public function addChild(container:Object, child:Object):void 18 | { 19 | if( container is Container ) 20 | { 21 | (container as Container).rawChildren.addChild(child as DisplayObject); 22 | } 23 | else 24 | { 25 | container.addChild( child as DisplayObject); 26 | } 27 | } 28 | 29 | public function removeChild(container:Object, child:Object):void 30 | { 31 | if( container is Container ) 32 | { 33 | (container as Container).rawChildren.removeChild(child as DisplayObject); 34 | } 35 | else 36 | { 37 | container.removeChild( child as DisplayObject); 38 | } 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/Flex4ChildManager.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import flash.display.DisplayObject; 4 | 5 | import mx.core.Container; 6 | import mx.core.IVisualElement; 7 | 8 | import spark.components.Group; 9 | 10 | /** 11 | * A class that knows how to add and remove children from a Flex 3 based component using 12 | * either addElement, addChild or rawChildren.addChild 13 | * 14 | * This class could always be used instead of Flex3ChildManager since it understand both, 15 | * but it won't compile under the Flex 3 SDK. 16 | **/ 17 | public class Flex4ChildManager implements IChildManager 18 | { 19 | 20 | public function addChild(container:Object, child:Object):void 21 | { 22 | if( container is Group ) 23 | { 24 | (container as Group).addElement( child as IVisualElement ); 25 | } 26 | else if( container is Container ) 27 | { 28 | (container as Container).rawChildren.addChild(child as DisplayObject); 29 | } 30 | else 31 | { 32 | container.addChild( child as DisplayObject); 33 | } 34 | } 35 | 36 | public function removeChild(container:Object, child:Object):void 37 | { 38 | 39 | if( container is Group ) 40 | { 41 | (container as Group).removeElement( child as IVisualElement ); 42 | } 43 | else if( container is Container ) 44 | { 45 | (container as Container).rawChildren.removeChild(child as DisplayObject); 46 | } 47 | else 48 | { 49 | container.removeChild( child as DisplayObject); 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/Flex4HandleFactory.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import mx.core.IFactory; 4 | 5 | /** 6 | * A simple factory class for Flex 4 based handles. 7 | ***/ 8 | public class Flex4HandleFactory implements IFactory 9 | { 10 | public function Flex4HandleFactory() 11 | { 12 | } 13 | 14 | public function newInstance():* 15 | { 16 | return new VisualElementHandle(); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/HandleClickedEvent.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import flash.events.Event; 4 | 5 | public class HandleClickedEvent extends Event 6 | { 7 | public static const HANDLE_CLICKED:String = "handleClicked"; 8 | 9 | public var clickedHandle:IHandle; 10 | 11 | public function HandleClickedEvent(handle:IHandle) 12 | { 13 | super(HANDLE_CLICKED, false, false); 14 | this.clickedHandle = handle; 15 | } 16 | 17 | override public function clone() : Event 18 | { 19 | return new HandleClickedEvent(clickedHandle); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/HandleDefinitions.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import flash.geom.Point; 4 | 5 | public class HandleDefinitions 6 | { 7 | public static const DEFAULT_DEFINITION:Array = [ 8 | new HandleDescription( HandleRoles.RESIZE_UP + HandleRoles.RESIZE_LEFT, 9 | new Point(0,0) , 10 | new Point(0,0) ), 11 | 12 | new HandleDescription( HandleRoles.RESIZE_UP , 13 | new Point(50,0) , 14 | new Point(0,0) ), 15 | 16 | new HandleDescription( HandleRoles.RESIZE_UP + HandleRoles.RESIZE_RIGHT, 17 | new Point(100,0) , 18 | new Point(0,0) ), 19 | 20 | new HandleDescription( HandleRoles.RESIZE_RIGHT, 21 | new Point(100,50) , 22 | new Point(0,0) ), 23 | 24 | new HandleDescription( HandleRoles.RESIZE_DOWN + HandleRoles.RESIZE_RIGHT, 25 | new Point(100,100) , 26 | new Point(0,0) ), 27 | 28 | new HandleDescription( HandleRoles.RESIZE_DOWN , 29 | new Point(50,100) , 30 | new Point(0,0) ), 31 | 32 | new HandleDescription( HandleRoles.RESIZE_DOWN + HandleRoles.RESIZE_LEFT, 33 | new Point(0,100) , 34 | new Point(0,0) ), 35 | 36 | new HandleDescription( HandleRoles.RESIZE_LEFT, 37 | new Point(0,50) , 38 | new Point(0,0) ), 39 | 40 | new HandleDescription( HandleRoles.ROTATE, 41 | new Point(100,50) , 42 | new Point(20,0) ) 43 | ]; 44 | 45 | public static const NO_ROTATE_DEFINITION:Array = [ 46 | new HandleDescription( HandleRoles.RESIZE_UP + HandleRoles.RESIZE_LEFT, 47 | new Point(0,0) , 48 | new Point(0,0) ), 49 | 50 | new HandleDescription( HandleRoles.RESIZE_UP , 51 | new Point(50,0) , 52 | new Point(0,0) ), 53 | 54 | new HandleDescription( HandleRoles.RESIZE_UP + HandleRoles.RESIZE_RIGHT, 55 | new Point(100,0) , 56 | new Point(0,0) ), 57 | 58 | new HandleDescription( HandleRoles.RESIZE_RIGHT, 59 | new Point(100,50) , 60 | new Point(0,0) ), 61 | 62 | new HandleDescription( HandleRoles.RESIZE_DOWN + HandleRoles.RESIZE_RIGHT, 63 | new Point(100,100) , 64 | new Point(0,0) ), 65 | 66 | new HandleDescription( HandleRoles.RESIZE_DOWN , 67 | new Point(50,100) , 68 | new Point(0,0) ), 69 | 70 | new HandleDescription( HandleRoles.RESIZE_DOWN + HandleRoles.RESIZE_LEFT, 71 | new Point(0,100) , 72 | new Point(0,0) ), 73 | 74 | new HandleDescription( HandleRoles.RESIZE_LEFT, 75 | new Point(0,50) , 76 | new Point(0,0) ) 77 | 78 | 79 | ]; 80 | public static const DEFAULT_PLUS_MOVE_DEFINITION:Array = [ 81 | new HandleDescription( HandleRoles.MOVE, 82 | new Point(50,50) , 83 | new Point(0,0) ), 84 | 85 | new HandleDescription( HandleRoles.RESIZE_UP + HandleRoles.RESIZE_LEFT, 86 | new Point(0,0) , 87 | new Point(0,0) ), 88 | 89 | new HandleDescription( HandleRoles.RESIZE_UP , 90 | new Point(50,0) , 91 | new Point(0,0) ), 92 | 93 | new HandleDescription( HandleRoles.RESIZE_UP + HandleRoles.RESIZE_RIGHT, 94 | new Point(100,0) , 95 | new Point(0,0) ), 96 | 97 | new HandleDescription( HandleRoles.RESIZE_RIGHT, 98 | new Point(100,50) , 99 | new Point(0,0) ), 100 | 101 | new HandleDescription( HandleRoles.RESIZE_DOWN + HandleRoles.RESIZE_RIGHT, 102 | new Point(100,100) , 103 | new Point(0,0) ), 104 | 105 | new HandleDescription( HandleRoles.RESIZE_DOWN , 106 | new Point(50,100) , 107 | new Point(0,0) ), 108 | 109 | new HandleDescription( HandleRoles.RESIZE_DOWN + HandleRoles.RESIZE_LEFT, 110 | new Point(0,100) , 111 | new Point(0,0) ), 112 | 113 | new HandleDescription( HandleRoles.RESIZE_LEFT, 114 | new Point(0,50) , 115 | new Point(0,0) ), 116 | 117 | new HandleDescription( HandleRoles.ROTATE, 118 | new Point(100,50) , 119 | new Point(20,0) ) 120 | ]; 121 | } 122 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/HandleDescription.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | package com.roguedevelopment.objecthandles 27 | { 28 | import flash.geom.Point; 29 | 30 | import mx.core.IFactory; 31 | 32 | public class HandleDescription 33 | { 34 | [Bindable] 35 | public var role:uint; 36 | public var percentageOffset:Point; 37 | public var offset:Point; 38 | public var handleFactory:IFactory; 39 | public var constraint:IFactory; 40 | 41 | 42 | /** 43 | * Creates a new handle description. 44 | * 45 | * @param role a value from HandleRoles 46 | * @param percentageOffset Where should this handle go as a percent of the height/width of the component? For instance (50,50) would center it 47 | * and (100,0) would be the top right corner. 48 | * 49 | * @param offset After the percentageOffset is applied, how many pixes should we offset the handle by? 50 | * @param handleFactory An IFactory that can create the DisplayObject for this handle. By default you get a grey box. Customize this 51 | * to have different handle graphics. 52 | * @param constraint Allows you to have custom constraints for some of the handles. 53 | * 54 | **/ 55 | public function HandleDescription(role:uint, percentageOffset:Point, offset:Point, handleFactory:IFactory = null, constraint:IFactory = null ) 56 | { 57 | this.role = role; 58 | this.percentageOffset = percentageOffset; 59 | this.offset = offset; 60 | this.handleFactory = handleFactory; 61 | this.constraint = constraint; 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/HandleRoles.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | package com.roguedevelopment.objecthandles 27 | { 28 | /** 29 | * Constants defining what role(s) a given handle is for. 30 | **/ 31 | public class HandleRoles 32 | { 33 | // NO_ROLE just sends the event out for the click 34 | public static const NO_ROLE : uint = 0; 35 | 36 | public static const RESIZE_UP : uint = 1; 37 | public static const RESIZE_DOWN : uint = 2; 38 | public static const RESIZE_LEFT : uint = 4; 39 | public static const RESIZE_RIGHT : uint = 8; 40 | public static const ROTATE : uint = 16; 41 | public static const MOVE : uint = 32; 42 | 43 | 44 | // some convienence methods: 45 | public static function isResize(val:uint) : Boolean 46 | { 47 | return isResizeDown(val) || isResizeLeft(val) || isResizeRight(val) || isResizeUp(val); 48 | } 49 | public static function isResizeUp( val:uint ) : Boolean 50 | { 51 | return (val & RESIZE_UP) == RESIZE_UP; 52 | } 53 | public static function isResizeDown( val:uint ) : Boolean 54 | { 55 | return (val & RESIZE_DOWN) == RESIZE_DOWN; 56 | } 57 | public static function isResizeLeft( val:uint ) : Boolean 58 | { 59 | return (val & RESIZE_LEFT) == RESIZE_LEFT; 60 | } 61 | public static function isResizeRight( val:uint ) : Boolean 62 | { 63 | return (val & RESIZE_RIGHT) == RESIZE_RIGHT; 64 | } 65 | public static function isRotate( val:uint ) : Boolean 66 | { 67 | return (val & ROTATE) == ROTATE; 68 | } 69 | 70 | public static function isMove( val:uint ) : Boolean 71 | { 72 | return (val & MOVE) == MOVE; 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/IChildManager.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | 4 | public interface IChildManager 5 | { 6 | function addChild( container:Object, child:Object ) : void; 7 | function removeChild( container:Object, child:Object ) : void; 8 | } 9 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/IConstraint.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | package com.roguedevelopment.objecthandles 27 | { 28 | import flash.geom.Rectangle; 29 | 30 | public interface IConstraint 31 | { 32 | function applyConstraint( original:DragGeometry, translation:DragGeometry, resizeHandleRole:uint ) : void; 33 | } 34 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/IHandle.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | package com.roguedevelopment.objecthandles 27 | { 28 | import flash.events.IEventDispatcher; 29 | 30 | public interface IHandle extends IEventDispatcher 31 | { 32 | function redraw():void; 33 | function get handleDescriptor():HandleDescription; 34 | function set handleDescriptor(value:HandleDescription):void; 35 | function get targetModel():Object; 36 | function set targetModel(value:Object):void; 37 | function get visible():Boolean; 38 | function set visible(value:Boolean):void; 39 | function get x():Number; 40 | function set x(value:Number):void; 41 | function get y():Number; 42 | function set y(value:Number):void; 43 | function get width():Number; 44 | function set width(value:Number):void; 45 | function get height():Number; 46 | function set height(value:Number):void; 47 | function get rotation():Number; 48 | function set rotation(value:Number):void; } 49 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/IMoveable.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | 27 | package com.roguedevelopment.objecthandles 28 | { 29 | public interface IMoveable 30 | { 31 | function get x() : Number; 32 | function get y() : Number; 33 | 34 | function set x(val : Number):void; 35 | function set y(val : Number):void; 36 | } 37 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/IResizeable.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | 27 | package com.roguedevelopment.objecthandles 28 | { 29 | public interface IResizeable 30 | { 31 | function get width() : Number; 32 | function get height() : Number; 33 | 34 | function set width(val : Number):void; 35 | function set height(val : Number):void; 36 | 37 | } 38 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/ObjectChangedEvent.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import flash.events.Event; 4 | 5 | public class ObjectChangedEvent extends Event 6 | { 7 | 8 | public static const OBJECT_MOVE_START:String = "objectMoveStart"; 9 | public static const OBJECT_RESIZE_START:String = "objectResizeStart"; 10 | public static const OBJECT_ROTATE_START:String = "objectRotateStart"; 11 | 12 | public static const OBJECT_MOVED:String = "objectMoved"; 13 | public static const OBJECT_RESIZED:String = "objectResized"; 14 | public static const OBJECT_ROTATED:String = "objectRotated"; 15 | 16 | public static const OBJECT_MOVING:String = "objectMoving"; 17 | public static const OBJECT_RESIZING:String = "objectResizing"; 18 | public static const OBJECT_ROTATING:String = "objectRotating"; 19 | 20 | /** 21 | * An array of objects that were moved/resized or rotated. 22 | **/ 23 | public var relatedObjects:Array; 24 | 25 | public function ObjectChangedEvent(relatedObjects:Array, type:String,bubbles:Boolean=false, cancelable:Boolean=false) 26 | { 27 | super(type, bubbles, cancelable); 28 | this.relatedObjects = relatedObjects; 29 | } 30 | 31 | public function set type(val:String):void 32 | { 33 | this.type = val; 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/ObjectHandlesSelectionManager.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | 27 | package com.roguedevelopment.objecthandles 28 | { 29 | import flash.events.EventDispatcher; 30 | import flash.geom.Matrix; 31 | import flash.geom.Point; 32 | import flash.geom.Rectangle; 33 | 34 | [Event(name="removedFromSelection", type="com.roguedevelopment.objecthandles.SelectionEvent")] 35 | [Event(name="selectionCleared", type="com.roguedevelopment.objecthandles.SelectionEvent")] 36 | [Event(name="addedToSelection", type="com.roguedevelopment.objecthandles.SelectionEvent")] 37 | public class ObjectHandlesSelectionManager extends EventDispatcher 38 | { 39 | public var currentlySelected:Array = []; 40 | 41 | 42 | public function ObjectHandlesSelectionManager() 43 | {} 44 | 45 | public function addToSelected( model:Object ) : void 46 | { 47 | 48 | if( currentlySelected.indexOf( model ) != -1 ) { return; } // already selected 49 | 50 | 51 | if( currentlySelected.length > 0 ){ 52 | var locked:Boolean = isSelectionLocked(); 53 | 54 | if( model.hasOwnProperty("isLocked") ) 55 | { 56 | if( locked && !model.isLocked ) { 57 | return; 58 | } 59 | 60 | if( !locked && model.isLocked ) { 61 | return; 62 | } 63 | } 64 | } 65 | 66 | 67 | 68 | currentlySelected.push(model); 69 | var event:SelectionEvent = new SelectionEvent( SelectionEvent.ADDED_TO_SELECTION ); 70 | event.targets.push( model ); 71 | dispatchEvent( event ); 72 | 73 | } 74 | 75 | public function isSelected( model:Object ) : Boolean 76 | { 77 | return currentlySelected.indexOf( model ) != -1; 78 | } 79 | 80 | public function setSelected( model:Object ) : void 81 | { 82 | 83 | clearSelection(); 84 | addToSelected( model ); 85 | } 86 | 87 | public function removeFromSelected( model:Object ) : void 88 | { 89 | var ind:int = currentlySelected.indexOf(model); 90 | if( ind == -1 ) { return; } 91 | 92 | currentlySelected.splice(ind,1); 93 | 94 | var event:SelectionEvent = new SelectionEvent( SelectionEvent.REMOVED_FROM_SELECTION); 95 | event.targets.push(model); 96 | dispatchEvent( event ); 97 | 98 | } 99 | 100 | public function clearSelection( ) : void 101 | { 102 | var event:SelectionEvent = new SelectionEvent( SelectionEvent.SELECTION_CLEARED ); 103 | event.targets = currentlySelected; 104 | currentlySelected = []; 105 | dispatchEvent( event ); 106 | } 107 | 108 | 109 | public function isSelectionLocked():Boolean { 110 | for each(var model:Object in currentlySelected) { 111 | if(model.hasOwnProperty("isLocked")) { 112 | if(model.isLocked) { 113 | return true; 114 | } 115 | } 116 | } 117 | 118 | return false; 119 | } 120 | 121 | 122 | public function getGeometry() : DragGeometry 123 | { 124 | var obj:Object; 125 | var rv:DragGeometry; 126 | // no selected objects 127 | if( currentlySelected.length == 0 ) { return null; } 128 | if( currentlySelected.length == 1) { 129 | // only one selected object 130 | obj = currentlySelected[0]; 131 | rv = new DragGeometry(); 132 | 133 | if( obj.hasOwnProperty("x") ) rv.x = obj["x"]; 134 | if( obj.hasOwnProperty("y") ) rv.y = obj["y"]; 135 | if( obj.hasOwnProperty("width") ) rv.width = obj["width"]; 136 | if( obj.hasOwnProperty("height") ) rv.height = obj["height"]; 137 | if( obj.hasOwnProperty("rotation") ) rv.rotation = obj["rotation"]; 138 | if( obj.hasOwnProperty("isLocked") ) rv.isLocked = obj["isLocked"]; 139 | 140 | return rv; 141 | } else { 142 | // a lot of selected objects 143 | return calculateMultiGeometry(); 144 | 145 | } 146 | return null; 147 | } 148 | 149 | protected function calculateMultiGeometry() : DragGeometry 150 | { 151 | var rv:DragGeometry; 152 | var lx1: Number = Number.POSITIVE_INFINITY; // top left bounds 153 | var ly1: Number = Number.POSITIVE_INFINITY; 154 | var lx2: Number = Number.NEGATIVE_INFINITY; // bottom right bounds 155 | var ly2: Number = Number.NEGATIVE_INFINITY; 156 | 157 | var matrix:Matrix = new Matrix(); 158 | var temp:Point = new Point(); 159 | var temp2:Point = new Point(); 160 | 161 | for each(var modelObject:Object in currentlySelected) 162 | { 163 | matrix.identity(); 164 | if( modelObject.hasOwnProperty("rotation") ) 165 | { 166 | matrix.rotate( toRadians(modelObject.rotation) ); 167 | } 168 | matrix.translate( modelObject.x, modelObject.y ); 169 | 170 | 171 | temp.x=0; // Check top left 172 | temp.y=0; 173 | temp = matrix.transformPoint(temp); 174 | 175 | lx1 = Math.min(lx1, temp.x ); 176 | ly1 = Math.min(ly1, temp.y ); 177 | lx2 = Math.max(lx2, temp.x ); 178 | ly2 = Math.max(ly2, temp.y ); 179 | 180 | temp.x=0; // Check bottom left 181 | temp.y=modelObject.height; 182 | temp = matrix.transformPoint(temp); 183 | lx1 = Math.min(lx1, temp.x ); 184 | ly1 = Math.min(ly1, temp.y ); 185 | lx2 = Math.max(lx2, temp.x ); 186 | ly2 = Math.max(ly2, temp.y ); 187 | 188 | temp.x=modelObject.width; // Check top right 189 | temp.y=0; 190 | temp = matrix.transformPoint(temp); 191 | lx1 = Math.min(lx1, temp.x ); 192 | ly1 = Math.min(ly1, temp.y ); 193 | lx2 = Math.max(lx2, temp.x ); 194 | ly2 = Math.max(ly2, temp.y ); 195 | 196 | temp.x=modelObject.width; // Check top right 197 | temp.y=modelObject.height; 198 | temp = matrix.transformPoint(temp); 199 | lx1 = Math.min(lx1, temp.x ); 200 | ly1 = Math.min(ly1, temp.y ); 201 | lx2 = Math.max(lx2, temp.x ); 202 | ly2 = Math.max(ly2, temp.y ); 203 | 204 | 205 | } 206 | rv = new DragGeometry(); 207 | rv.rotation = 0; 208 | rv.x = lx1; 209 | rv.y = ly1; 210 | rv.width = lx2 - lx1; 211 | rv.height = ly2 - ly1; 212 | rv.isLocked = isSelectionLocked(); 213 | return rv; 214 | } 215 | 216 | protected static function toRadians( degrees:Number ) :Number 217 | { 218 | return degrees * Math.PI / 180; 219 | } 220 | 221 | public function getGeometryForObject(a:Object) : DragGeometry 222 | { 223 | // Just return coordinates of object 224 | 225 | var obj:Object = a; 226 | var rv:DragGeometry = new DragGeometry(); 227 | 228 | if( obj.hasOwnProperty("x") ) rv.x = obj["x"]; 229 | if( obj.hasOwnProperty("y") ) rv.y = obj["y"]; 230 | if( obj.hasOwnProperty("width") ) rv.width = obj["width"]; 231 | if( obj.hasOwnProperty("height") ) rv.height = obj["height"]; 232 | if( obj.hasOwnProperty("rotation") ) rv.rotation = obj["rotation"]; 233 | if( obj.hasOwnProperty("isLocked") ) rv.isLocked = obj["isLocked"]; 234 | 235 | return rv; 236 | } 237 | 238 | 239 | } 240 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/SelectionEvent.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | 27 | package com.roguedevelopment.objecthandles 28 | { 29 | import flash.events.Event; 30 | 31 | public class SelectionEvent extends Event 32 | { 33 | public static const REMOVED_FROM_SELECTION:String = "removedFromSelection"; 34 | public static const SELECTION_CLEARED:String = "selectionCleared"; 35 | public static const ADDED_TO_SELECTION:String = "addedToSelection"; 36 | public static const SELECTED:String = "selected"; 37 | 38 | public var targets:Array = []; 39 | 40 | public function SelectionEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) 41 | { 42 | super(type, bubbles, cancelable); 43 | } 44 | 45 | } 46 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/SpriteHandle.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | 27 | 28 | /** 29 | * A handle implementation based on Sprite, primarily for use in Flex 3. 30 | **/ 31 | package com.roguedevelopment.objecthandles 32 | { 33 | import flash.display.Sprite; 34 | import flash.events.MouseEvent; 35 | 36 | public class SpriteHandle extends Sprite implements IHandle 37 | { 38 | /** 39 | * Some global settings for the handle representation. Set using class, not instance!!! 40 | * 41 | * Use to change the size of the handles. 42 | * usage: SpriteHandle.handleSize=8; 43 | **/ 44 | public static var handleSize:Number = 10; 45 | 46 | /** 47 | * Use to change the fill color of the handles. 48 | * usage: SpriteHandle.handleColor=0xff0000; 49 | **/ 50 | public static var handleColor:int = 0xaaaaaa; 51 | 52 | /** 53 | * Use to change the OVER fill color of the handles. 54 | * usage: SpriteHandle.handleColorOver=0x0000ff; 55 | **/ 56 | public static var handleColorOver:int = 0xc5ffc0; 57 | 58 | /** 59 | * Use to change the border of the handle. 60 | * usage: SpriteHandle.borderWidth=2; 61 | **/ 62 | public static var borderWidth:Number = 1.0; 63 | 64 | /** 65 | * Use to change the stroke/line/border color of the handles. 66 | * usage: SpriteHandle.handleBorderColor=0xff00ff; 67 | **/ 68 | public static var handleBorderColor:int = 0x000000; 69 | 70 | /** 71 | * Use to change the OVER stroke/line/border color of the handles. 72 | * usage: SpriteHandle.handleBorderColorOver=0x00ff00; 73 | **/ 74 | public static var handleBorderColorOver:int = 0x3dff40; 75 | 76 | private var _descriptor:HandleDescription; 77 | private var _targetModel:Object; 78 | protected var isOver:Boolean = false; 79 | 80 | public function get handleDescriptor():HandleDescription 81 | { 82 | return _descriptor; 83 | } 84 | public function set handleDescriptor(value:HandleDescription):void 85 | { 86 | _descriptor = value; 87 | } 88 | public function get targetModel():Object 89 | { 90 | return _targetModel; 91 | } 92 | public function set targetModel(value:Object):void 93 | { 94 | _targetModel = value; 95 | } 96 | 97 | public function SpriteHandle() 98 | { 99 | super(); 100 | addEventListener( MouseEvent.ROLL_OUT, onRollOut ); 101 | addEventListener( MouseEvent.ROLL_OVER, onRollOver ); 102 | //redraw(); 103 | } 104 | 105 | protected function onRollOut( event : MouseEvent ) : void 106 | { 107 | isOver = false; 108 | redraw(); 109 | } 110 | protected function onRollOver( event:MouseEvent):void 111 | { 112 | isOver = true; 113 | redraw(); 114 | } 115 | 116 | public function redraw() : void 117 | { 118 | graphics.clear(); 119 | if( isOver ) 120 | { 121 | graphics.lineStyle(borderWidth,handleBorderColorOver); 122 | graphics.beginFill(handleColorOver,1); 123 | } 124 | else 125 | { 126 | graphics.lineStyle(borderWidth,handleBorderColor); 127 | graphics.beginFill(handleColor,1); 128 | } 129 | 130 | graphics.drawRect(-handleSize/2,-handleSize/2,handleSize,handleSize); 131 | graphics.endFill(); 132 | 133 | } 134 | 135 | } 136 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/VisualElementHandle.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import flash.events.MouseEvent; 4 | 5 | import spark.core.SpriteVisualElement; 6 | 7 | /** 8 | * A handle class based on SpriteVisualElement which is suitable for adding to 9 | * a Flex 4 Group based container. 10 | **/ 11 | public class VisualElementHandle extends SpriteVisualElement implements IHandle 12 | { 13 | 14 | private var _descriptor:HandleDescription; 15 | private var _targetModel:Object; 16 | protected var isOver:Boolean = false; 17 | 18 | public function get handleDescriptor():HandleDescription 19 | { 20 | return _descriptor; 21 | } 22 | public function set handleDescriptor(value:HandleDescription):void 23 | { 24 | _descriptor = value; 25 | } 26 | public function get targetModel():Object 27 | { 28 | return _targetModel; 29 | } 30 | public function set targetModel(value:Object):void 31 | { 32 | _targetModel = value; 33 | } 34 | 35 | public function VisualElementHandle() 36 | { 37 | super(); 38 | addEventListener( MouseEvent.ROLL_OUT, onRollOut ); 39 | addEventListener( MouseEvent.ROLL_OVER, onRollOver ); 40 | //redraw(); 41 | } 42 | 43 | protected function onRollOut( event : MouseEvent ) : void 44 | { 45 | isOver = false; 46 | redraw(); 47 | } 48 | protected function onRollOver( event:MouseEvent):void 49 | { 50 | isOver = true; 51 | redraw(); 52 | } 53 | 54 | public function redraw() : void 55 | { 56 | graphics.clear(); 57 | if( isOver ) 58 | { 59 | graphics.lineStyle(1,0x3dff40); 60 | graphics.beginFill(0xc5ffc0 ,1); 61 | } 62 | else 63 | { 64 | graphics.lineStyle(1,0); 65 | graphics.beginFill(0xaaaaaa,1); 66 | } 67 | 68 | graphics.drawRect(-5,-5,10,10); 69 | graphics.endFill(); 70 | 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/constraints/MaintainProportionConstraint.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | package com.roguedevelopment.objecthandles.constraints 27 | { 28 | import com.roguedevelopment.objecthandles.DragGeometry; 29 | import com.roguedevelopment.objecthandles.HandleRoles; 30 | import com.roguedevelopment.objecthandles.IConstraint; 31 | 32 | import flash.geom.Matrix; 33 | import flash.geom.Point; 34 | 35 | 36 | /** 37 | * This is a constraint which causes the resized component to maintain a constant aspect ration. 38 | * 39 | **/ 40 | 41 | public class MaintainProportionConstraint implements IConstraint 42 | { 43 | private var origin:Point = new Point(0,0); 44 | 45 | 46 | public function applyConstraint(original:DragGeometry, translation:DragGeometry, resizeHandleRole:uint):void 47 | { 48 | if( ! HandleRoles.isResize( resizeHandleRole ) ) return; 49 | 50 | var originalProportion:Number = original.width / original.height; // x/y 51 | var possiblePos1:Point = new Point( translation.width, translation.width / originalProportion ); 52 | var possiblePos2:Point = new Point( translation.height * originalProportion, translation.height ); 53 | var originalPoint:Point = new Point( translation.width, translation.height); 54 | var distance1:Number = Point.distance( possiblePos1, originalPoint ); 55 | var distance2:Number = Point.distance( possiblePos2, originalPoint ); 56 | 57 | var target:Point; 58 | 59 | if( !(HandleRoles.isResizeDown(resizeHandleRole) || HandleRoles.isResizeUp(resizeHandleRole)) ) 60 | { 61 | // only resize left/right 62 | target = possiblePos1 ; 63 | } 64 | else if( !(HandleRoles.isResizeLeft(resizeHandleRole) || HandleRoles.isResizeRight(resizeHandleRole)) ) 65 | { 66 | // only resize up/down 67 | target = possiblePos2; 68 | } 69 | else 70 | { 71 | target = distance1 < distance2 ? possiblePos1 : possiblePos2; 72 | } 73 | 74 | translation.width = target.x; 75 | translation.height = target.y; 76 | 77 | 78 | 79 | } 80 | 81 | 82 | 83 | 84 | } 85 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/constraints/MovementConstraint.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | 27 | package com.roguedevelopment.objecthandles.constraints 28 | { 29 | import com.roguedevelopment.objecthandles.DragGeometry; 30 | import com.roguedevelopment.objecthandles.HandleRoles; 31 | import com.roguedevelopment.objecthandles.IConstraint; 32 | 33 | /** 34 | * This is a constraint that makes an object stay within a certain bounds. 35 | * 36 | * This isn't really done yet. It doesn't handle rotated objects well 37 | **/ 38 | public class MovementConstraint implements IConstraint 39 | { 40 | public var minX:Number; 41 | public var minY:Number; 42 | public var maxX:Number; 43 | public var maxY:Number; 44 | 45 | public function applyConstraint( original:DragGeometry, translation:DragGeometry, resizeHandleRole:uint ) : void 46 | { 47 | // Both are required for the logic to work 48 | if(!original || !translation) return; 49 | 50 | if(!isNaN(maxX)) 51 | { 52 | if((original.x + translation.x + original.width + 53 | translation.width) > maxX) 54 | { 55 | if(HandleRoles.isMove(resizeHandleRole)) 56 | { 57 | translation.x = maxX - (original.x + original.width); 58 | } 59 | else if(HandleRoles.isResizeRight(resizeHandleRole)) 60 | { 61 | translation.width = maxX - (original.x + translation.x + 62 | original.width); 63 | 64 | } 65 | } 66 | } 67 | 68 | if(!isNaN(maxY)) 69 | { 70 | if((original.y + translation.y + original.height + 71 | translation.height) > maxY) 72 | { 73 | if(HandleRoles.isMove(resizeHandleRole)) 74 | { 75 | translation.y = maxY - (original.y + original.height); 76 | } 77 | else if(HandleRoles.isResizeDown(resizeHandleRole)) 78 | { 79 | translation.height = maxY - (original.y + translation.y + 80 | original.height); 81 | 82 | } 83 | } 84 | } 85 | 86 | if(!isNaN(minX)) 87 | { 88 | if((original.x + translation.x) < minX) 89 | { 90 | translation.x = minX - original.x; 91 | } 92 | if(HandleRoles.isResizeLeft(resizeHandleRole) && original.x - 93 | translation.width < minX) 94 | { 95 | translation.width = - minX + original.x; 96 | } 97 | } 98 | 99 | if(!isNaN(minY)) 100 | { 101 | if((original.y + translation.y) < minY) 102 | { 103 | translation.y = minY - original.y; 104 | } 105 | if(HandleRoles.isResizeUp(resizeHandleRole) && original.y - 106 | translation.height < minY) 107 | { 108 | translation.height = - minY + original.y; 109 | } 110 | 111 | } 112 | } 113 | 114 | } 115 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/constraints/SizeConstraint.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.html 3 | * 4 | * Copyright (c) 2009 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * See README for more information. 24 | * 25 | **/ 26 | 27 | package com.roguedevelopment.objecthandles.constraints 28 | { 29 | import com.roguedevelopment.objecthandles.DragGeometry; 30 | import com.roguedevelopment.objecthandles.IConstraint; 31 | 32 | public class SizeConstraint implements IConstraint 33 | { 34 | public var maxWidth:Number; 35 | public var minWidth:Number; 36 | public var maxHeight:Number; 37 | public var minHeight:Number; 38 | 39 | public function applyConstraint( original:DragGeometry, translation:DragGeometry, resizeHandleRole:uint ) : void 40 | { 41 | // Both are required for the logic to work 42 | if(!original || !translation) return; 43 | 44 | if( ! isNaN( maxWidth ) ) 45 | { 46 | if( (original.width + translation.width) > maxWidth ) 47 | { 48 | translation.width = maxWidth - original.width; 49 | } 50 | } 51 | 52 | if( ! isNaN( maxHeight ) ) 53 | { 54 | if( (original.height + translation.height) > maxHeight ) 55 | { 56 | translation.height = maxHeight - original.height; 57 | } 58 | } 59 | 60 | if( ! isNaN( minWidth ) ) 61 | { 62 | if( (original.width + translation.width) < minWidth ) 63 | { 64 | translation.width = minWidth - original.width; 65 | } 66 | } 67 | 68 | if( ! isNaN( minHeight ) ) 69 | { 70 | if( (original.height + translation.height) < minHeight ) 71 | { 72 | translation.height = minHeight - original.height; 73 | } 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/decorators/AlignmentDecorator.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.decorators 2 | { 3 | import flash.display.Sprite; 4 | 5 | public class AlignmentDecorator implements IDecorator 6 | { 7 | public function AlignmentDecorator() 8 | { 9 | } 10 | 11 | 12 | public function updateSelected(allObject:Array, selectedObjects:Array, drawingCanvas:Sprite):void 13 | { 14 | drawingCanvas.graphics.clear(); 15 | } 16 | 17 | public function updatePosition(allObject:Array, selectedObjects:Array, movedObjects:Array, drawingCanvas:Sprite):void 18 | { 19 | if( selectedObjects.length != 1 ) return; 20 | var o:Object = selectedObjects[0]; 21 | drawingCanvas.graphics.clear(); 22 | drawingCanvas.graphics.lineStyle(1,0x00aaaa,1); 23 | for each ( var other:Object in allObject ) 24 | { 25 | if( other == o ) continue; 26 | if( Math.abs(o.x-other.x) < 1 ) drawVerticalLine(other.x,drawingCanvas); 27 | if( Math.abs(o.y-other.y) < 1 ) drawHorizontalLine(other.y,drawingCanvas); 28 | if( Math.abs((o.x+o.width)-(other.x+other.width)) < 1 ) drawVerticalLine(other.x+other.width,drawingCanvas); 29 | if( Math.abs((o.y+o.height)-(other.y + other.height)) < 1 ) drawHorizontalLine(other.y+other.height,drawingCanvas); 30 | 31 | if( Math.abs(o.x-(other.width+other.x)) < 1 ) drawVerticalLine(o.x,drawingCanvas); 32 | if( Math.abs(o.y-(other.y+other.height)) < 1 ) drawHorizontalLine(o.y,drawingCanvas); 33 | if( Math.abs((o.x+o.width)-other.x) < 1 ) drawVerticalLine(o.x+o.width,drawingCanvas); 34 | if( Math.abs((o.y+o.height)-other.y) < 1 ) drawHorizontalLine(o.y+o.height,drawingCanvas); 35 | 36 | } 37 | 38 | } 39 | 40 | 41 | protected function drawVerticalLine( x:Number, sprite:Sprite ) : void 42 | { 43 | sprite.graphics.moveTo(x,0); 44 | sprite.graphics.lineTo(x,3000); 45 | } 46 | protected function drawHorizontalLine( y:Number, sprite:Sprite ) : void 47 | { 48 | sprite.graphics.moveTo(0,y); 49 | sprite.graphics.lineTo(3000,y); 50 | } 51 | 52 | public function cleanup(drawingCanvas:Sprite):void 53 | { 54 | drawingCanvas.graphics.clear(); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/decorators/DecoratorManager.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.decorators 2 | { 3 | 4 | 5 | import com.roguedevelopment.objecthandles.ObjectChangedEvent; 6 | import com.roguedevelopment.objecthandles.ObjectHandles; 7 | import com.roguedevelopment.objecthandles.SelectionEvent; 8 | 9 | import flash.display.Sprite; 10 | import flash.events.Event; 11 | 12 | public class DecoratorManager 13 | { 14 | protected var drawLayer:Sprite; 15 | protected var decorators:Array = []; 16 | protected var subDrawLayers:Object = {}; 17 | protected var objectHandles:ObjectHandles; 18 | 19 | public function DecoratorManager(objectHandles:ObjectHandles, drawLayer:Sprite) 20 | { 21 | this.drawLayer = drawLayer; 22 | this.objectHandles = objectHandles; 23 | 24 | objectHandles.selectionManager.addEventListener(SelectionEvent.ADDED_TO_SELECTION, onSelectionChanged ); 25 | objectHandles.selectionManager.addEventListener(SelectionEvent.REMOVED_FROM_SELECTION, onSelectionChanged ); 26 | objectHandles.selectionManager.addEventListener(SelectionEvent.SELECTION_CLEARED, onSelectionChanged ); 27 | objectHandles.selectionManager.addEventListener(SelectionEvent.SELECTED, onSelectionChanged ); 28 | 29 | objectHandles.addEventListener(ObjectChangedEvent.OBJECT_MOVING, onPositionChanged ); 30 | objectHandles.addEventListener(ObjectChangedEvent.OBJECT_RESIZING, onPositionChanged ); 31 | objectHandles.addEventListener(ObjectChangedEvent.OBJECT_ROTATING, onPositionChanged ); 32 | 33 | } 34 | 35 | public function updateNow() : void 36 | { 37 | for each(var decorator:IDecorator in decorators ) 38 | { 39 | decorator.updateSelected( objectHandles.modelList, objectHandles.selectionManager.currentlySelected, subDrawLayers[decorator] ); 40 | decorator.updatePosition( objectHandles.modelList, objectHandles.selectionManager.currentlySelected,objectHandles.modelList ,subDrawLayers[decorator] ); 41 | } 42 | } 43 | 44 | protected function onSelectionChanged(event:Event):void 45 | { 46 | for each(var decorator:IDecorator in decorators ) 47 | { 48 | decorator.updateSelected( objectHandles.modelList, objectHandles.selectionManager.currentlySelected, subDrawLayers[decorator] ); 49 | } 50 | 51 | } 52 | 53 | protected function onPositionChanged(event:ObjectChangedEvent):void 54 | { 55 | for each(var decorator:IDecorator in decorators ) 56 | { 57 | decorator.updatePosition( objectHandles.modelList, objectHandles.selectionManager.currentlySelected, event.relatedObjects ,subDrawLayers[decorator] ); 58 | } 59 | 60 | } 61 | public function addDecorator( decorator:IDecorator ) : void 62 | { 63 | var subDrawLayer:Sprite = new Sprite(); 64 | drawLayer.addChild(subDrawLayer); 65 | 66 | decorators.push(decorator); 67 | subDrawLayers[decorator] = subDrawLayer; 68 | } 69 | 70 | 71 | 72 | } 73 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/decorators/IDecorator.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.decorators 2 | { 3 | import flash.display.Sprite; 4 | 5 | public interface IDecorator 6 | { 7 | function updateSelected( allObject:Array, selectedObjects:Array, drawingCanvas:Sprite ) : void; 8 | function updatePosition( allObject:Array, selectedObjects:Array, movedObjects:Array, drawingCanvas:Sprite ) : void; 9 | function cleanup(drawingCanvas:Sprite ):void; 10 | } 11 | 12 | 13 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/decorators/OutlineDecorator.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.decorators 2 | { 3 | import com.roguedevelopment.objecthandles.ObjectHandles; 4 | 5 | import flash.display.Sprite; 6 | 7 | /** 8 | * This is an example decorator that draws a white border around all the selected objects. 9 | **/ 10 | public class OutlineDecorator implements IDecorator 11 | { 12 | /** 13 | * Some global settings for the decorator. Set using class, not instance!!! 14 | * 15 | * Use to change the width border. 16 | * usage: OutlineDecorator.lineWidth=2; 17 | **/ 18 | public static var lineWidth:Number = 5; 19 | 20 | /** 21 | * Use to change the line color. 22 | * usage: OutlineDecorator.lineColor=0xff0000; 23 | **/ 24 | public static var lineColor:int = 0xeeeeee; 25 | 26 | /** 27 | * Use to change the line alpha. 28 | * usage: OutlineDecorator.lineAlpha=0.6; 29 | **/ 30 | public static var lineAlpha:Number = 1; 31 | 32 | public function OutlineDecorator() 33 | { 34 | } 35 | 36 | protected function updateDecoration(selectedObjects:Array, drawingCanvas:Sprite):void 37 | { 38 | drawingCanvas.graphics.clear(); 39 | drawingCanvas.graphics.lineStyle( lineWidth, lineColor, lineAlpha ); 40 | 41 | for each ( var model:Object in selectedObjects ) 42 | { 43 | drawingCanvas.graphics.drawRect( model.x, model.y, model.width, model.height ); 44 | } 45 | } 46 | 47 | public function updateSelected( allObject:Array, selectedObjects:Array, drawingCanvas:Sprite ) : void 48 | { 49 | updateDecoration( selectedObjects, drawingCanvas ); 50 | } 51 | public function updatePosition( allObject:Array, selectedObjects:Array, movedObjects:Array, drawingCanvas:Sprite ) : void 52 | { 53 | updateDecoration( selectedObjects, drawingCanvas ); 54 | } 55 | public function cleanup(drawingCanvas:Sprite ):void 56 | { 57 | drawingCanvas.graphics.clear(); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/decorators/WebDecorator.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.decorators 2 | { 3 | import flash.display.Sprite; 4 | 5 | /** 6 | * This is a sample decorator that draws lines between all the objects. 7 | **/ 8 | public class WebDecorator implements IDecorator 9 | { 10 | public function WebDecorator() 11 | { 12 | } 13 | 14 | protected function drawWeb( objects:Array, drawingCanvas:Sprite):void 15 | { 16 | drawingCanvas.graphics.clear(); 17 | drawingCanvas.graphics.lineStyle(5,0x777777); 18 | for( var i:int = 1 ; i < objects.length ; i++ ) 19 | { 20 | for( var j:int=(i+1) ; j < objects.length ; j++ ) 21 | { 22 | drawingCanvas.graphics.moveTo( objects[i].x + objects[i].width/2, objects[i].y + objects[i].height/2 ); 23 | drawingCanvas.graphics.lineTo( objects[j].x + objects[j].width/2, objects[j].y + objects[j].height/2 ); 24 | } 25 | } 26 | 27 | } 28 | 29 | public function updateSelected(allObject:Array, selectedObjects:Array, drawingCanvas:Sprite):void 30 | { 31 | drawWeb(allObject,drawingCanvas); 32 | 33 | } 34 | 35 | public function updatePosition(allObject:Array, selectedObjects:Array, movedObjects:Array, drawingCanvas:Sprite):void 36 | { 37 | drawWeb(allObject,drawingCanvas); 38 | } 39 | 40 | public function cleanup(drawingCanvas:Sprite):void 41 | { 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/DegrafaHandle.mxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 30 | 31 | 34 | 39 | 40 | 41 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/Example1.mxml: -------------------------------------------------------------------------------- 1 | 2 | 29 | 30 | 33 | 34 | 44 | 45 | 104 | 105 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/Example2.mxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 16 | 17 | 18 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/Example3.mxml: -------------------------------------------------------------------------------- 1 | 2 | 29 | 30 | 33 | 34 | 43 | 44 | 159 | 160 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/Example4.mxml: -------------------------------------------------------------------------------- 1 | 2 | 29 | 30 | 33 | 34 | 43 | 44 | 45 | 94 | 95 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/Example5.mxml: -------------------------------------------------------------------------------- 1 | 2 | 29 | 30 | 33 | 34 | 43 | 44 | 45 | 46 | 76 | 77 | 78 | 79 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/Example6.mxml: -------------------------------------------------------------------------------- 1 | 2 | 29 | 30 | 33 | 34 | 44 | 45 | 96 | 97 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/Example7.mxml: -------------------------------------------------------------------------------- 1 | 2 | 29 | 30 | 33 | 34 | 44 | 45 | 92 | 93 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/Example8.mxml: -------------------------------------------------------------------------------- 1 | 2 | 29 | 30 | 33 | 34 | 44 | 45 | 113 | 114 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/Flex4Example1.mxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 14 | 15 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/MoveableTextArea.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.example 2 | { 3 | import flash.events.Event; 4 | 5 | import mx.controls.TextArea; 6 | import mx.events.PropertyChangeEvent; 7 | 8 | /** 9 | * This is an example and not part of the core ObjectHandles library. 10 | **/ 11 | 12 | public class MoveableTextArea extends TextArea 13 | { 14 | protected var _model:TextDataModel; 15 | 16 | public function MoveableTextArea() 17 | { 18 | super(); 19 | addEventListener(Event.CHANGE, onTextInput ); 20 | } 21 | 22 | public function set model( val:TextDataModel ) : void 23 | { 24 | if( _model ) _model.removeEventListener( PropertyChangeEvent.PROPERTY_CHANGE, onPropertyChange ); 25 | _model = val; 26 | reposition(); 27 | 28 | val.addEventListener( PropertyChangeEvent.PROPERTY_CHANGE, onPropertyChange ); 29 | } 30 | 31 | protected function onTextInput(event:Event ):void 32 | { 33 | if( _model ) { _model.text = text; } 34 | } 35 | protected function onPropertyChange(event:PropertyChangeEvent ) : void 36 | { 37 | reposition(); 38 | } 39 | protected function reposition() : void 40 | { 41 | drawFocus(false); 42 | x = _model.x; 43 | y = _model.y; 44 | width = _model.width; 45 | height = _model.height; 46 | rotation = _model.rotation; 47 | text = _model.text; 48 | } 49 | 50 | } 51 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/SimpleDataModel.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.example 2 | { 3 | import com.roguedevelopment.objecthandles.IMoveable; 4 | import com.roguedevelopment.objecthandles.IResizeable; 5 | 6 | 7 | /** 8 | * This is an example and not part of the core ObjectHandles library. 9 | **/ 10 | 11 | public class SimpleDataModel implements IResizeable, IMoveable 12 | { 13 | [Bindable] public var x:Number = 10; 14 | [Bindable] public var y:Number = 10; 15 | [Bindable] public var height:Number = 50; 16 | [Bindable] public var width:Number = 50; 17 | [Bindable] public var rotation:Number = 0; 18 | [Bindable] public var isLocked:Boolean = false; 19 | } 20 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/SimpleFlex4Shape.mxml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/SimpleFlexShape.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.example 2 | { 3 | import mx.core.UIComponent; 4 | import mx.events.PropertyChangeEvent; 5 | 6 | 7 | /** 8 | * This is an example and not part of the core ObjectHandles library. 9 | **/ 10 | 11 | public class SimpleFlexShape extends UIComponent 12 | { 13 | protected var _model:SimpleDataModel; 14 | 15 | public function SimpleFlexShape() 16 | { 17 | super(); 18 | } 19 | 20 | public function set model( model:SimpleDataModel ) : void 21 | { 22 | if( _model ) 23 | { 24 | _model.removeEventListener( PropertyChangeEvent.PROPERTY_CHANGE, onModelChange ); 25 | } 26 | _model = model; 27 | redraw(); 28 | x = model.x; 29 | y = model.y; 30 | model.addEventListener( PropertyChangeEvent.PROPERTY_CHANGE, onModelChange ); 31 | } 32 | 33 | override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void 34 | { 35 | redraw(); 36 | } 37 | 38 | protected function onModelChange( event:PropertyChangeEvent):void 39 | { 40 | switch( event.property ) 41 | { 42 | case "x": x = event.newValue as Number; break; 43 | case "y": y = event.newValue as Number; break; 44 | case "rotation": rotation = event.newValue as Number; break; 45 | case "width": 46 | case "height": break; 47 | default: return; 48 | } 49 | redraw(); 50 | } 51 | 52 | protected function redraw() : void 53 | { 54 | if(!_model){return;} 55 | graphics.clear(); 56 | graphics.lineStyle(1,0); 57 | graphics.beginFill(0x555555,0.6); 58 | graphics.drawRoundRect(0,0,_model.width,_model.height,0,0); 59 | graphics.endFill(); 60 | } 61 | 62 | } 63 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/SimpleSpriteShape.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.example 2 | { 3 | import flash.display.Sprite; 4 | 5 | import mx.events.PropertyChangeEvent; 6 | 7 | 8 | /** 9 | * This is an example and not part of the core ObjectHandles library. 10 | **/ 11 | 12 | public class SimpleSpriteShape extends Sprite 13 | { 14 | protected var model:SimpleDataModel; 15 | public function SimpleSpriteShape(model:SimpleDataModel) 16 | { 17 | super(); 18 | this.model = model; 19 | model.addEventListener( PropertyChangeEvent.PROPERTY_CHANGE, onModelChange ); 20 | x = model.x; 21 | y = model.y; 22 | redraw(); 23 | } 24 | 25 | protected function onModelChange( event:PropertyChangeEvent):void 26 | { 27 | switch( event.property ) 28 | { 29 | case "x": x = event.newValue as Number; break; 30 | case "y": y = event.newValue as Number; break; 31 | case "rotation": rotation = event.newValue as Number; break; 32 | case "width": 33 | case "height": break; 34 | default: return; 35 | } 36 | redraw(); 37 | } 38 | 39 | protected function redraw() : void 40 | { 41 | graphics.clear(); 42 | graphics.lineStyle(1,0); 43 | graphics.beginFill(0xB3EAFF,1); 44 | graphics.drawRoundRect(0,0,model.width,model.height,0,0); 45 | graphics.endFill(); 46 | } 47 | 48 | 49 | } 50 | } -------------------------------------------------------------------------------- /flex-object-handles-2/src/com/roguedevelopment/objecthandles/example/TextDataModel.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles.example 2 | { 3 | 4 | /** 5 | * This is an example and not part of the core ObjectHandles library. 6 | **/ 7 | 8 | public class TextDataModel extends SimpleDataModel 9 | { 10 | [Bindable] public var text:String; 11 | } 12 | } -------------------------------------------------------------------------------- /flex-object-handles/.actionScriptProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /flex-object-handles/.flexProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /flex-object-handles/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ObjectHandles 4 | 5 | 6 | 7 | 8 | 9 | com.adobe.flexbuilder.project.flexbuilder 10 | 11 | 12 | 13 | 14 | 15 | com.adobe.flexbuilder.project.flexnature 16 | com.adobe.flexbuilder.project.actionscriptnature 17 | 18 | 19 | -------------------------------------------------------------------------------- /flex-object-handles/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | #Wed May 20 08:55:24 EDT 2009 2 | eclipse.preferences.version=1 3 | encoding/=utf-8 4 | -------------------------------------------------------------------------------- /flex-object-handles/src/MoveAndResize.mxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/AppStarting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/AppStarting.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/Arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/Arrow.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/Cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/Cross.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/Hand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/Hand.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/Handwriting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/Handwriting.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/Help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/Help.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/IBeam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/IBeam.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/Link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/Link.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/NO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/NO.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/SizeAll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/SizeAll.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/SizeNESW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/SizeNESW.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/SizeNS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/SizeNS.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/SizeNWSE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/SizeNWSE.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/SizeWE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/SizeWE.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/UpArrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/UpArrow.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/blue/Wait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/blue/Wait.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/cursor/horizontalSize.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/cursor/horizontalSize.gif -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/cursor/leftObliqueSize.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/cursor/leftObliqueSize.gif -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/cursor/mouseMove.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/cursor/mouseMove.gif -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/cursor/rightObliqueSize.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/cursor/rightObliqueSize.gif -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/cursor/verticalSize.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/cursor/verticalSize.gif -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/AppStarting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/AppStarting.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/Arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/Arrow.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/Cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/Cross.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/Hand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/Hand.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/Handwriting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/Handwriting.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/Help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/Help.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/IBeam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/IBeam.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/Link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/Link.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/NO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/NO.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/SizeAll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/SizeAll.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/SizeNESW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/SizeNESW.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/SizeNS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/SizeNS.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/SizeNWSE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/SizeNWSE.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/SizeWE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/SizeWE.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/UpArrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/UpArrow.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/light/Wait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/light/Wait.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set1/pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set1/pointer.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set1/resize-h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set1/resize-h.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set1/resize-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set1/resize-l.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set1/resize-r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set1/resize-r.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set1/resize-v.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set1/resize-v.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set2/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set2/move.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set2/pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set2/pointer.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set2/resize-h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set2/resize-h.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set2/resize-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set2/resize-l.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set2/resize-r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set2/resize-r.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set2/resize-v.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set2/resize-v.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set3/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set3/move.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set3/pointer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set3/pointer.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set3/resize-h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set3/resize-h.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set3/resize-l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set3/resize-l.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set3/resize-r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set3/resize-r.png -------------------------------------------------------------------------------- /flex-object-handles/src/assets/cursors/set3/resize-v.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/assets/cursors/set3/resize-v.png -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/FixedRatioObjectHandles.as: -------------------------------------------------------------------------------- 1 | 2 | // This functionality is now contained in the main ObjectHandles class, just enable either the alwaysMaintainAspectRatio or cornerMaintainAspectRatio properties 3 | 4 | 5 | package com.roguedevelopment.objecthandles 6 | { 7 | 8 | public class FixedRatioObjectHandles extends ObjectHandles 9 | { 10 | public function FixedRatioObjectHandles() 11 | { 12 | alwaysMaintainAspectRatio = true; 13 | super(); 14 | } 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/Handle.as: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | 5 | Usage of this class is being deprecated. We're just always going to use an ImageHandle so there's 6 | a single set of code to maintain. The default "image" looks nearly identical to what this handle 7 | used to draw. 8 | 9 | */ 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | /** 37 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.xml 38 | * 39 | * Copyright (c) 2008 Marc Hughes 40 | * 41 | * Permission is hereby granted, free of charge, to any person obtaining a 42 | * copy of this software and associated documentation files (the "Software"), 43 | * to deal in the Software without restriction, including without limitation 44 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 45 | * and/or sell copies of the Software, and to permit persons to whom the Software 46 | * is furnished to do so, subject to the following conditions: 47 | * 48 | * The above copyright notice and this permission notice shall be included in all 49 | * copies or substantial portions of the Software. 50 | * 51 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 52 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 53 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 54 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 55 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 56 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 57 | * 58 | * 59 | * 60 | **/ 61 | 62 | /** 63 | * This class represents one of the small boxes drawn around the object that can be dragged to resize or rotate 64 | **/ 65 | package com.roguedevelopment.objecthandles 66 | { 67 | import mx.core.UIComponent; 68 | import flash.events.MouseEvent; 69 | import flash.events.Event; 70 | 71 | public class Handle extends UIComponent 72 | { 73 | 74 | 75 | // Does this handle let us resize down? 76 | public var resizeDown:Boolean = false; 77 | 78 | // Does this handle let us resize up? 79 | public var resizeUp:Boolean = false; 80 | 81 | // Does this handle let us resize left? 82 | public var resizeLeft:Boolean = false; 83 | 84 | // Does this handle let us resize to the right? 85 | public var resizeRight:Boolean = false; 86 | 87 | protected var _rotate:Boolean; 88 | public function set rotate(val:Boolean):void { _rotate=val; draw(); } 89 | public function get rotate():Boolean { return _rotate; } 90 | 91 | public function Handle() 92 | { 93 | super(); 94 | width = 4; 95 | height = 4; 96 | } 97 | 98 | protected function draw() : void 99 | { 100 | graphics.clear(); 101 | // TODO: Draw prettier handles. 102 | if( rotate ) 103 | { 104 | graphics.lineStyle(1,0x888888); 105 | graphics.beginFill(0x888888,0.3); 106 | graphics.drawCircle(0,0,4); 107 | graphics.moveTo(-2,0); 108 | graphics.lineTo(-28,0); 109 | graphics.endFill(); 110 | } 111 | else 112 | { 113 | graphics.lineStyle(1,0x888888); 114 | graphics.beginFill(0x888888,0.3); 115 | graphics.drawRect(0,0,4,4); 116 | graphics.endFill(); 117 | } 118 | } 119 | 120 | /** 121 | * Returns true if this handle represents a handle in a corner. 122 | **/ 123 | public function isCorner() : Boolean 124 | { 125 | return 2 == ( ( resizeUp ? 1 : 0 ) + 126 | ( resizeDown ? 1 : 0 ) + 127 | ( resizeLeft ? 1 : 0 ) + 128 | ( resizeRight ? 1 : 0 ) ); // Corners can resize in exactly 2 directions. 129 | } 130 | 131 | public function getCursorName() : String 132 | { 133 | if( !resizeDown && resizeLeft && !resizeRight && resizeUp ) 134 | { 135 | return "SizeNWSE"; 136 | } 137 | if( resizeDown && !resizeLeft && resizeRight && !resizeUp ) 138 | { 139 | return "SizeNWSE"; 140 | } 141 | if( !resizeDown && !resizeLeft && resizeRight && resizeUp ) 142 | { 143 | return "SizeNESW"; 144 | } 145 | if( resizeDown && resizeLeft && !resizeRight && !resizeUp ) 146 | { 147 | return "SizeNESW"; 148 | } 149 | if( resizeDown && !resizeLeft && !resizeRight && !resizeUp ) 150 | { 151 | return "SizeNS"; 152 | } 153 | if( !resizeDown && !resizeLeft && !resizeRight && resizeUp ) 154 | { 155 | return "SizeNS"; 156 | } 157 | if( !resizeDown && resizeLeft && !resizeRight && !resizeUp ) 158 | { 159 | return "SizeWE"; 160 | } 161 | if( !resizeDown && !resizeLeft && resizeRight && !resizeUp ) 162 | { 163 | return "SizeWE"; 164 | } 165 | 166 | if( rotate ) 167 | { 168 | return "SizeAll"; 169 | } 170 | return ""; 171 | } 172 | 173 | 174 | } 175 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/ImageHandle.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import flash.display.Bitmap; 4 | import flash.events.Event; 5 | 6 | import mx.controls.Image; 7 | 8 | public class ImageHandle extends Handle 9 | { 10 | 11 | public function ImageHandle(image:Class) 12 | { 13 | super(); 14 | 15 | var bm:Bitmap = new image(); 16 | addChild(bm); 17 | 18 | width = bm.width; 19 | height = bm.height; 20 | bm.x = 0; 21 | bm.y = 0; 22 | 23 | 24 | } 25 | 26 | 27 | private function errorLoading(event:Event):void{ 28 | super.draw(); 29 | } 30 | 31 | protected override function draw():void 32 | { 33 | 34 | } 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/MouseCursorDetails.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.xml 3 | * 4 | * Copyright (c) 2008 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | **/ 23 | 24 | package com.roguedevelopment.objecthandles 25 | { 26 | import flash.geom.Point; 27 | 28 | public class MouseCursorDetails 29 | { 30 | public var cursor:Class; 31 | public var offset:Point; 32 | 33 | public function MouseCursorDetails( cursor:Class, offsetX:Number, offsetY:Number) 34 | { 35 | this.cursor = cursor; 36 | offset = new Point(offsetX, offsetY ); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/OHMouseCursors.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | public interface OHMouseCursors 4 | { 5 | function getCursor(name:String) : MouseCursorDetails; 6 | } 7 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/ObjectHandleEvent.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.xml 3 | * 4 | * Copyright (c) 2008 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * 24 | * 25 | **/ 26 | 27 | /** 28 | * This class represents the events that can be dispatched by the ObjectHandles class. 29 | * 30 | * These events are dispatched on the completion of a user gesture. So if a user slowly resizes 31 | * an object over a long distance, only one event is dispatched at the end of that action. 32 | * 33 | * For resizing to the left or up, both move and resize events are dispatched. 34 | * 35 | **/ 36 | package com.roguedevelopment.objecthandles 37 | { 38 | import flash.events.Event; 39 | 40 | public class ObjectHandleEvent extends Event 41 | { 42 | 43 | /** Dispatched once a move action has completed. 44 | **/ 45 | public static const OBJECT_MOVED_EVENT:String = "objectMovedEvent"; 46 | 47 | /** Dispatched once a resize action has completed. 48 | **/ 49 | public static const OBJECT_RESIZED_EVENT:String = "objectResizedEvent"; 50 | 51 | /** Dispatched while the object is resizing for each incremental resize. 52 | **/ 53 | public static const OBJECT_RESIZING_EVENT:String = "objectResizingEvent"; 54 | 55 | /** Dispatched once a resize action has completed. 56 | **/ 57 | public static const OBJECT_ROTATED_EVENT:String = "objectRotatedEvent"; 58 | 59 | /** Dispatched while the object is resizing for each incremental resize. 60 | **/ 61 | public static const OBJECT_ROTATING_EVENT:String = "objectRotatingEvent"; 62 | 63 | 64 | /** Dispatched while the object is moving for each incremental move. 65 | **/ 66 | public static const OBJECT_MOVING_EVENT:String = "objectMovingEvent"; 67 | 68 | /** 69 | * Dispatched when the user selects the object. 70 | **/ 71 | public static const OBJECT_SELECTED:String = "objectSelected"; 72 | 73 | /** Dispatched when the user deselects the object. 74 | **/ 75 | public static const OBJECT_DESELECTED:String = "objectDeselected"; 76 | 77 | public function ObjectHandleEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) 78 | { 79 | super(type, bubbles, cancelable); 80 | } 81 | 82 | } 83 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/ObjectHandlesCanvas.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.objecthandles 2 | { 3 | import flash.display.DisplayObject; 4 | 5 | import mx.containers.Canvas; 6 | import mx.managers.IFocusManagerComplexComponent; 7 | 8 | /** 9 | * This class provides keyboard navigation to the ObjectHandles within it. 10 | * 11 | * You don't have to use this to use ObjectHandles, but then you won't get keyboard nav. 12 | * 13 | * TODO: visible=false object handles can still be tabbed to. 14 | * 15 | **/ 16 | public class ObjectHandlesCanvas extends Canvas implements IFocusManagerComplexComponent 17 | { 18 | protected var objectHandles:Array = []; 19 | 20 | protected var currentOH:ObjectHandles; 21 | 22 | public function ObjectHandlesCanvas() 23 | { 24 | super(); 25 | tabChildren = false; 26 | tabEnabled = true; 27 | focusEnabled = true; 28 | 29 | } 30 | 31 | 32 | public function advanceFocus(from:ObjectHandles) : Boolean 33 | { 34 | return moveFocus( from, false ); 35 | } 36 | protected function moveFocus( from:ObjectHandles, backwards:Boolean ) :Boolean 37 | { 38 | var items:Array = objectHandles.concat(); 39 | items.sort( sortByPosition ); 40 | 41 | 42 | 43 | var ind:int = items.indexOf( from ); 44 | if(backwards) 45 | { 46 | ind--; 47 | } 48 | else 49 | { 50 | ind++; 51 | } 52 | if( ind == -1 ){ return false; } 53 | if( ind == -2 ){ ind = items.length-1; } 54 | if( ind >= items.length ) 55 | { 56 | return false; 57 | } 58 | currentOH = items[ind] as ObjectHandles; 59 | items[ind].setKeyboardFocus(); 60 | return true; 61 | } 62 | 63 | override public function setFocus():void 64 | { 65 | advanceFocus(null); 66 | } 67 | 68 | public function retreatFocus(from:ObjectHandles) : Boolean 69 | { 70 | return moveFocus( from, true ); 71 | } 72 | 73 | protected function sortByPosition( first:ObjectHandles, second:ObjectHandles ) : Number 74 | { 75 | if(first.y < second.y ) { return -1; } 76 | if(first.y > second.y ) { return 1; } 77 | 78 | if(first.x < second.x ) { return -1; } 79 | if(first.x > second.x ) { return 1; } 80 | 81 | return 0; 82 | } 83 | 84 | 85 | protected function sortChildren() : void 86 | { 87 | var i:int = 0; 88 | var sortedChildren:Array = []; 89 | for( i = 0 ; i < numChildren ; i++) 90 | { 91 | sortedChildren.push( getChildAt(i) ); 92 | } 93 | 94 | sortedChildren.sort( comparator ); 95 | i=0; 96 | for each ( var d:DisplayObject in sortedChildren ) 97 | { 98 | setChildIndex(d, i ); 99 | i++; 100 | } 101 | } 102 | 103 | override public function removeChild(child:DisplayObject):DisplayObject 104 | { 105 | if( (child is ObjectHandles ) && (objectHandles.indexOf(child) != -1) ) 106 | { 107 | objectHandles.splice(objectHandles.indexOf(child),1); 108 | } 109 | super.removeChild(child); 110 | return child; 111 | } 112 | 113 | protected function comparator( obj1:Object , obj2:Object ) : Number 114 | { 115 | var so1:Number = obj1 is ObjectHandles ? 116 | (obj1 as ObjectHandles).sortOrder : 117 | obj1.hasOwnProperty("sortOrder") ? 118 | obj1.sortOrder 119 | : 0 ; 120 | 121 | 122 | var so2:Number = obj2 is ObjectHandles ? 123 | (obj2 as ObjectHandles).sortOrder : 124 | obj2.hasOwnProperty("sortOrder") ? 125 | obj2.sortOrder 126 | : 0 ; 127 | 128 | if( so1 > so2 ) { return 1; } 129 | if( so1 < so2 ) { return -1; } 130 | return 0; 131 | } 132 | 133 | override public function addChildAt(child:DisplayObject, index:int):DisplayObject 134 | { 135 | if( child is ObjectHandles ) 136 | { 137 | objectHandles.push(child); 138 | } 139 | 140 | super.addChildAt(child,index); 141 | sortChildren(); 142 | return child; 143 | } 144 | 145 | 146 | public function get hasFocusableContent():Boolean 147 | { 148 | return objectHandles.length > 0; 149 | } 150 | 151 | public function assignFocus(direction:String):void 152 | { 153 | if( direction == "top" ) 154 | { 155 | advanceFocus(null); 156 | } 157 | else 158 | { 159 | retreatFocus(null); 160 | } 161 | 162 | // The first time we tab in, we also set that item selected. 163 | // After that, we only change focus. 164 | if( currentOH ) 165 | { 166 | SelectionManager.instance.setSelected( currentOH ); 167 | } 168 | } 169 | 170 | } 171 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/ObjectHandlesMouseCursors.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.xml 3 | * 4 | * Copyright (c) 2008 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * ------------------------------------------------------------------------------------------- 24 | * 25 | * Cursor graphics Copyright (C) Dunkelstern and released under an MIT license. 26 | * 27 | **/ 28 | 29 | package com.roguedevelopment.objecthandles 30 | { 31 | import flash.display.Loader; 32 | import mx.core.FlexSprite; 33 | import flash.utils.Dictionary; 34 | import flash.ui.Mouse; 35 | import mx.managers.CursorManager; 36 | import mx.controls.SWFLoader; 37 | import flash.events.Event; 38 | import flash.display.MovieClip; 39 | import mx.managers.PopUpManager; 40 | import mx.core.FlexMovieClip; 41 | import mx.core.UIComponent; 42 | import flash.events.MouseEvent; 43 | 44 | public class ObjectHandlesMouseCursors implements OHMouseCursors 45 | { 46 | [Embed("../../../assets/cursors/blue/SizeNS.png")] 47 | protected var sizeNS:Class; 48 | [Embed("../../../assets/cursors/blue/SizeAll.png")] 49 | protected var sizeAll:Class; 50 | [Embed("../../../assets/cursors/blue/SizeNESW.png")] 51 | protected var sizeNESW:Class; 52 | [Embed("../../../assets/cursors/blue/SizeNWSE.png")] 53 | protected var sizeNWSE:Class; 54 | [Embed("../../../assets/cursors/blue/SizeWE.png")] 55 | protected var sizeWE:Class; 56 | 57 | protected var map:Object = new Object(); 58 | 59 | public function getCursor(name:String) : MouseCursorDetails 60 | { 61 | return map[name]; 62 | } 63 | 64 | public function ObjectHandlesMouseCursors() : void 65 | { 66 | map["SizeNS"] = new MouseCursorDetails(sizeNS, -6, -15 ); 67 | map["SizeAll"] = new MouseCursorDetails(sizeAll, -15, -15 ); 68 | map["SizeNESW"] = new MouseCursorDetails(sizeNESW, -10, -10 ); 69 | map["SizeNWSE"] = new MouseCursorDetails(sizeNWSE, -10, -10 ); 70 | map["SizeWE"] = new MouseCursorDetails(sizeWE, -15, -6 ); 71 | } 72 | 73 | } 74 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/ObjectHandlesMouseCursors2.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.xml 3 | * 4 | * Copyright (c) 2008 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * ------------------------------------------------------------------------------------------- 24 | * 25 | * Cursor graphics Copyright (C) Evi Skitsanos, contrubted to project. 26 | * 27 | **/ 28 | package com.roguedevelopment.objecthandles 29 | { 30 | public class ObjectHandlesMouseCursors2 implements OHMouseCursors 31 | { 32 | [Embed("../../../assets/cursors/set1/resize-v.png")] 33 | protected var sizeNS:Class; 34 | [Embed("../../../assets/cursors/set2/move.png")] 35 | protected var sizeAll:Class; 36 | [Embed("../../../assets/cursors/set1/resize-l.png")] 37 | protected var sizeNESW:Class; 38 | [Embed("../../../assets/cursors/set1/resize-r.png")] 39 | protected var sizeNWSE:Class; 40 | [Embed("../../../assets/cursors/set1/resize-h.png")] 41 | protected var sizeWE:Class; 42 | 43 | protected var map:Object = new Object(); 44 | 45 | public function getCursor(name:String) : MouseCursorDetails 46 | { 47 | return map[name]; 48 | } 49 | 50 | public function ObjectHandlesMouseCursors2() : void 51 | { 52 | map["SizeNS"] = new MouseCursorDetails(sizeNS, -5, -8 ); 53 | map["SizeAll"] = new MouseCursorDetails(sizeAll, -11, -13 ); 54 | map["SizeNWSE"] = new MouseCursorDetails(sizeNESW, -5, -6 ); 55 | map["SizeNESW"] = new MouseCursorDetails(sizeNWSE, -5, -6 ); 56 | map["SizeWE"] = new MouseCursorDetails(sizeWE, -9, -6 ); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/Selectable.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.xml 3 | * 4 | * Copyright (c) 2008 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * 24 | * 25 | * ------------------------------------------------------------------------------------------- 26 | * 27 | * 28 | * 29 | * 30 | **/ 31 | 32 | package com.roguedevelopment.objecthandles 33 | { 34 | public interface Selectable 35 | { 36 | function select() : void; 37 | function deselect() : void; 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/SelectionManager.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Latest information on this project can be found at http://www.rogue-development.com/objectHandles.xml 3 | * 4 | * Copyright (c) 2008 Marc Hughes 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a 7 | * copy of this software and associated documentation files (the "Software"), 8 | * to deal in the Software without restriction, including without limitation 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | * and/or sell copies of the Software, and to permit persons to whom the Software 11 | * is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 17 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | * 23 | * 24 | * 25 | * ------------------------------------------------------------------------------------------- 26 | * 27 | * 28 | * 29 | * 30 | **/ 31 | 32 | package com.roguedevelopment.objecthandles 33 | { 34 | public class SelectionManager 35 | { 36 | private static var _instance:SelectionManager; 37 | private var _items:Array = new Array(); 38 | [Bindable] 39 | public var currentlySelected:Selectable = null; 40 | 41 | public static function get instance() : SelectionManager 42 | { 43 | if( ! _instance ) { _instance = new SelectionManager(); } 44 | return _instance; 45 | } 46 | 47 | public function selectNone() : void 48 | { 49 | setSelected(null); 50 | } 51 | 52 | public function setSelected(obj:Selectable) : void 53 | { 54 | if( obj == currentlySelected ) { return; } 55 | 56 | if( currentlySelected != null ) 57 | { 58 | currentlySelected.deselect(); 59 | } 60 | 61 | currentlySelected = obj; 62 | 63 | if( obj != null ) 64 | { 65 | currentlySelected.select(); 66 | } 67 | 68 | 69 | } 70 | 71 | public function getItems():Array 72 | { 73 | return _items; 74 | } 75 | 76 | public function addSelectable(obj:Selectable) : void 77 | { 78 | var ind:int = _items.indexOf( obj ); 79 | if( ind != -1 ) { return; } 80 | 81 | _items.push(obj); 82 | } 83 | 84 | public function removeSelectable( obj : Selectable ) : void 85 | { 86 | var ind:int = _items.indexOf( obj ); 87 | if( ind == -1 ) { return; } 88 | _items.splice( ind , 1 ); 89 | 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/SizeAll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/com/roguedevelopment/objecthandles/SizeAll.png -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/SizeNESW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/com/roguedevelopment/objecthandles/SizeNESW.png -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/SizeNS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/com/roguedevelopment/objecthandles/SizeNS.png -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/SizeNWSE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/com/roguedevelopment/objecthandles/SizeNWSE.png -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/SizeWE.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/com/roguedevelopment/objecthandles/SizeWE.png -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/resizeHandle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/com/roguedevelopment/objecthandles/resizeHandle.png -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/resizeHandle.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/com/roguedevelopment/objecthandles/resizeHandle.psd -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/rotateHandle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/com/roguedevelopment/objecthandles/rotateHandle.png -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/objecthandles/rotateHandle.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/com/roguedevelopment/objecthandles/rotateHandle.psd -------------------------------------------------------------------------------- /flex-object-handles/src/com/roguedevelopment/popupbar/PopupBar.as: -------------------------------------------------------------------------------- 1 | package com.roguedevelopment.popupbar 2 | { 3 | import mx.controls.Button; 4 | import mx.collections.ArrayCollection; 5 | import flash.events.MouseEvent; 6 | import mx.events.FlexEvent; 7 | import mx.controls.Image; 8 | import mx.containers.HBox; 9 | import mx.core.ScrollPolicy; 10 | import mx.controls.List; 11 | import mx.containers.VBox; 12 | import mx.managers.PopUpManager; 13 | import flash.geom.Point; 14 | 15 | public class PopupBar extends HBox 16 | { 17 | public var items:Array; 18 | 19 | [Bindable] public var selectedIndex:Number = 0; 20 | 21 | protected var image:Image; 22 | 23 | public function PopupBar() 24 | { 25 | super(); 26 | 27 | horizontalScrollPolicy = ScrollPolicy.OFF; 28 | verticalScrollPolicy = ScrollPolicy.OFF; 29 | 30 | addEventListener(MouseEvent.CLICK, onClick ); 31 | addEventListener(MouseEvent.MOUSE_OVER, onMouseOver ); 32 | addEventListener(MouseEvent.MOUSE_OUT, onMouseOut ); 33 | addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown ); 34 | addEventListener(MouseEvent.MOUSE_UP, onMouseUp ); 35 | 36 | addEventListener(FlexEvent.CREATION_COMPLETE, init ); 37 | 38 | mouseChildren=false; 39 | mouseEnabled=true; 40 | 41 | image = new Image(); 42 | addChild(image); 43 | } 44 | 45 | 46 | 47 | protected function init(event:FlexEvent) : void 48 | { 49 | setIcon("up"); 50 | } 51 | 52 | protected function setIcon(state:String) : void 53 | { 54 | image.source = items[selectedIndex] + "_" + state + ".png"; 55 | 56 | } 57 | 58 | protected function onClick(event:MouseEvent) : void 59 | { 60 | var list:VBox = new VBox(); 61 | for each (var item:String in items) 62 | { 63 | var subImage:Image = new Image(); 64 | subImage.source = item + "_up.png"; 65 | list.addChild(subImage); 66 | } 67 | 68 | 69 | PopUpManager.addPopUp(list,this); 70 | var p:Point = localToGlobal(new Point(x,y) ); 71 | list.x = p.x; 72 | list.y = p.y; 73 | } 74 | 75 | protected function onMouseDown(event:MouseEvent) : void 76 | { 77 | setIcon("dwn"); 78 | } 79 | 80 | protected function onMouseUp(event:MouseEvent) : void 81 | { 82 | setIcon("ovr"); 83 | } 84 | protected function onMouseOver(event:MouseEvent) : void 85 | { 86 | setIcon("ovr"); 87 | } 88 | protected function onMouseOut(event:MouseEvent) : void 89 | { 90 | setIcon("up"); 91 | } 92 | 93 | } 94 | } -------------------------------------------------------------------------------- /flex-object-handles/src/resize_handle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/resize_handle.png -------------------------------------------------------------------------------- /flex-object-handles/src/rotate_handle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/rotate_handle.png -------------------------------------------------------------------------------- /flex-object-handles/src/snowflake.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marc-hughes/ObjectHandles/e263d7f7b3a7c813b79443d61e0d3284f53b7758/flex-object-handles/src/snowflake.png --------------------------------------------------------------------------------