Jump to content
Search Community

Firing Events From Mouse Clicks [SOLVED]

dave test
Moderator Tag

Recommended Posts

Hi there,

I'm having a strange problem firing the moveSelectionDepthUp()/moveSelectionDepthDown() methods when clicking on a SPRITE in my Flash app.

 

This works:

var thisItem : CanvasItem = new CanvasItem(e.droppedItem._itemDataObject);
thisItem.x = mouseX;
thisItem.y = mouseY;
itemsContainer.addChild(thisItem);			
thisItem.addEventListener(MouseEvent.CLICK, transformEventHandler);
transformManager.addItem(thisItem);

private function transformEventHandler(e : MouseEvent) : void
{
transformManager.moveSelectionDepthUp();
}

 

Now, here's what I want to do which is NOT working...

button_bringForward.addEventListener(MouseEvent.CLICK, transformEventHandler);

 

Any ideas? I assume it's some kind of a scoping issue but I can't get it sorted. Interacting with the actual items themselves works but nothing else...

Thank you very much. I'm loving this tool by the way!

Link to comment
Share on other sites

Ah I've figured that when I click my button, it's automatically deselecting the item so there isn't actually a selected item when my AS is fired. The only way to get it to work that I can see is to set autoDeselect to false. But then I can't deselect my items! I'm going to have to hack around this and add an event listener to pick up on mouse clicks on the stage area the items sit on which will "deselectAll()"

 

If anybody knows of a better way, please do tell!

Link to comment
Share on other sites

when I click my button, it's automatically deselecting the item so there isn't actually a selected item when my AS is fired. The only way to get it to work that I can see is to set autoDeselect to false. But then I can't deselect my items!

 

You're absolutely right. But I have good news. I just sent out an update a few minutes ago that adds a new "ignoredObjects" property and "addIgnoredObject()" and "removeIgnoredObject()" methods that allow you to simply tell TransformManager to ignore clicks on particular DisplayObjects (like buttons, form elements, etc.). That should make it pretty easy to accomplish what you're after.

 

Enjoy!

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...