A very common UI element found in many applications are those little square handles around an on-screen object that allow you to move & resize it. I haven't been able to find anything like that pre-built in flex, so I've started a project to develop one. It behaves as a container object so you can put any other flex component inside it and get the resizeable functionality right away.
Popularity
As of January of 2008 ObjectHandles has been downloaded over 28,000 times! We just started a page on the google wiki to show off projects using ObjectHandles. If you're using it we'd love to put a link up. Visit http://code.google.com/p/flex-object-handles/wiki/ObjectHandlesUsage and post a comment, we'll update the wiki page next time we see it.
Shameless Plug
I use ObjectHandles in a project scheduling application called AgileAgenda, currently in beta you should give it a try.
Features
- Move & Resize Functionality for any flex component
- Ability to limit movement and/or resizing in both vertical and horizontal directions
- Ability to limit movement and/or resizing along an anchor
- Simple 1-file (.swc) install
- Mouse cursors change when over different handles
- Graphical handle support
- Aspect ratio support
- Initial rotatation support has been added
Current Progress
The basic functionality all works.
Downloads
Download From Google CodeMailing List
We're using Google Groups for discussions, subscribe to it to hear about new releases, etc.
|
|
| Subscribe to Flex ObjectHandles |
| Visit this group |
Documentation
Tutorial
Here's a 14 minute tutorial showing you how to make a simple diagraming application.
Example Usage
First, download the .swc above. Then add it to your FlexBuilder project library path. Then you can use it to your heart's content in your mxml.
In the example below you'll see two buttons in a vbox that can be moved together. This is the mxml to achieve that:
<oh:ObjectHandles x="10" y="158" width="107" height="108"
minHeight="30" minWidth="30">
<mx:VBox borderStyle="none" top="0" left="0" right="0" bottom="0">
<mx:Button width="100%" height="50%" />
<mx:Button width="100%" height="50%" />
</mx:VBox>
</oh:ObjectHandles>
You can get the full mxml source for the application below here.
Example
Actionscript Example
Here's an example to dynamically load an image into an ObjectHandle and allow movement.
protected function init() : void
{
var oh:ObjectHandles = new ObjectHandles();
oh.height = 50;
oh.width = 50;
var image:Image = new Image();
image.source = "snowflake.png";
image.percentHeight = 100;
image.percentWidth = 100;
image.maintainAspectRatio = false;
oh.addChild(image);
oh.allowRotate = false;
genericExamples.addChild(oh); // replace genericExamples with a canvas in your application
}
Degrafa Example
Here's an example that integrated with Degrafa
http://rogue-development.com/objectHandles/degrafaExample/OH_Degrafa.html
Contribute
Find this useful? Want to help? I've set up a page listing various ways that you can contribute to this or some of my other projects.
Contact
The GoogleGroups mailing list above is the primary forum for communication about this project. Please direct questions or comments there.License
This component is licensed under the MIT license.
Copyright (c) 2008 Marc Hughes
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Rogue-Development.com