Jump to content
Search Community

Working with the IDs of transform items in Flex

Handycam test
Moderator Tag

Recommended Posts

I was wondering how I could access/manage the IDs of individual transform items, especially those I add dynamically.

 

I was thinking two things:

1. get what was clicked on. So if the user clicks on an image of a dog, I display dog items (as in "if e.currentTarget.id =='collie' then showDogs()")

 

Your sample code is working with the array of all selected items, how to wok with individual items in the selection?

private function onSelectionChange($e:TransformEvent):void {
	trace("Changed selection. Items just selected/deselected (changed): " + $e.items.length + ", total items now selected: " + myManager.selectedItems.length);}

 

2. select all the items with some specified ID(s), such as "select all dogs"

Link to comment
Share on other sites

Actually, that's not true - the TransformEvent's items array is populated with only the items that were affected by that particular event. So for example, if item A is selected and then the user CTRL-clicks on item B (to add it to the selection), the items array for that TransformEvent would only be populated with item B because the event didn't change anything about item A's state. See what I mean? But if they didn't CTRL-click, and just clicked instead, it would deselect item A and select item B which means they were both affected by the event, and the items array would be populated with them both. You could certainly loop through the items in the array and check the "selected" property of each to find out which one(s) was selected. You an also add SELECT and/or DESELECT event listeners to individual TransformItems so that you can sense when a particular one is selected/deselected. Lots of flexibility.

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