|
HintsAndTips
Some hints and tips for using ObjectHandles before I get real documentation done.
More Help?Need more help than this page gives? The best place to ask is our google group. http://groups.google.com/group/objecthandles Hints and TipsDeselecting an objectCall SelectionManager.instance.selectNone() to unselect the current item. Useful in a menu option, when dialogs pop up or the user clicks the "background". After I added this into my app, it all started to feel a lot more polished. User interaction of child componentsIf you want to allow the user to interact with child components inside ObjectHandles, do something like this: var oh:ObjectHandles = ....
oh.mouseChildren = true;
childComponent.editable = true;
childComponent.setFocus();
oh.allowVMove = false;
oh.allowHMove = false;
oh.showHandles(false);I do something like that on a double-click to allow the user to edit a text field inside a resizeable object. Using a repeater to dynamicaly create ObjectHandles<repeater dataProvider="{someSource}" id="repeater"> <oh:ObjectHandles><cust:MyComponent data="{repeater.currentItem}" /></oh:ObjectHandles> </repeater> Makes life really easy since the repeater worries about creation/deletion of objects as my internal data model changes. (Excuse any syntax errors, typing without an IDE). Custom Mouse CursorsNow, you can also set your own mouse cursors, outside of the library. To do this, implement the OHMouseCursors interface, instantiate your class, and assign it to the ObjectHandles.mouseCursors property. A sample cursor class follows: package your.package { public class YourMouseCursorClass implements OHMouseCursors { [Embed("../../../assets /cursors/set1/resize- v.png")] protected var sizeNS:Class; [Embed("../../../assets/cursors/set2/move.png")] protected var sizeAll:Class; [Embed("../../../assets/cursors/set1/resize- l.png")] protected var sizeNESW:Class; [Embed("../../../assets/cursors/set1/resize-r.png")] protected var sizeNWSE:Class; [Embed("../../../assets/cursors/set1/resize- h.png")] protected var sizeWE:Class; protected var map:Object = new Object(); public function getCursor(name:String) : MouseCursorDetails { return mapname; } public function YourMouseCursorClass () : void { // Numbers are offsets to the hot-spot of the cursor (the point of the arrow, the middle of the resize bar, etc.) map["SizeNS"] = new MouseCursorDetails(sizeNS, -5, -8 ); map["SizeAll"] = new MouseCursorDetails(sizeAll, -11, -13 ); map["SizeNWSE"] = new MouseCursorDetails(sizeNESW, -5, -6 ); map["SizeNESW"] = new MouseCursorDetails(sizeNWSE, -5, -6 ); map["SizeWE"] = new MouseCursorDetails(sizeWE, -9, -6 ); } } } Then in your mxml... <oh:objecthandles mousecursors="{new YourMouseCursorClass()}" allowrotate="false" x="10" y="90" width="307" height="30" minheight="30" minwidth="100"> If you have many ObjectHandles objects around, you can reuse the same cursor class to reduce memory usage. Rotating Text?You must embed the font to get the text to show up. This is a general Flash player limitation. Note, if you're using the TLF in Flash Player 10, this isn't a requirement. |
Sign in to add a comment
i want to resize text. when it resize so i want to also increase font size so can u help me...
Great Stuff Marc!!!
I think there's a typo in the "Custom Mouse Cursors" section above. The following line...
public function getCursor(name:String) : MouseCursorDetails? { return mapname; }
...should read...
public function getCursor(name:String) : MouseCursorDetails? { return mapname?; }
-Ted
Ha! My comment has the same typo. It should be this.
map name
not "mapname"
First of all, thanks very much for starting this project! It has really helped me in my projects.
I was just wondering whether there is a solution for the first comment in this thread. Is there a double click function to be able to get inside the rectangle to edit text?
Thanks
Hi, this works great ! But i have an issue when i want to resize a MovieClip? (from Flash) with a centered Registration Point. Any way to set the Regristration Point of the ObjectHandles? to Center ? Thanks. Max
How can i customize the resize icon and that should be different for each corner Please send me this info if any knows how to do. Thanks a lot.