Jump to content
Search Community

addSelectionBoxElement to Specific TransformItems

mattsonl test
Moderator Tag

Recommended Posts

I am attempting to use "addSelectionBoxElement" to add an edit button to a selected object in my application. After working with it a bit, I've realized that it is a TransformManager method, so it adds that edit button to every single TransformItem associated with my TransformManager. What I am trying to do is only add the edit button to specific TransformItems (for example I have Shapes, TextField, images, etc). Is there any way to only add the edit button for specific objects, or to hide the edit button when certain objects are selected? Thanks for your help.

Link to comment
Share on other sites

Ok, I am still a bit confused on how you actually access the custom element to set its visibility? So just as a very simple example, I have the following:

 

myManager = new TransformManager();
var square:Sprite = new Sprite();
square.graphics.beginFill(0x0000FF);
square.graphics.drawRect(0,0,80,30);
square.graphics.endFill();
myManager.addSelectionBoxElement(square, "bottomRight", -80, 0);

myManager.addEventListener(TransformEvent.SELECTION_CHANGE, onselectionchange, false, 0, true);


var mcItem:TransformItem = myManager.addItem(myObject, TransformManager.SCALE_NORMAL, false);


private function onselectionchange(e:TransformEvent):void {
  //???
}

 

So, within the onselectionchange listener, how do I access the "square" from the selected object?

Link to comment
Share on other sites

Here's some pseudo code that I had in mind:

 

private function onselectionchange(e:TransformEvent):void {
   square.visible = true; // by default, we'll start with it on...
   var targets:Array = myManager.selectedTargetObjects;
   for (var i:int = 0; i < targets.length; i++) {
       if ( [your conditional logic] ) {
           square.visible = false;
       }
   }
} 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...