Jump to content
Nezarov

Add and remove items | TransformItem

Recommended Posts

Hello, I am trying to remove some items from the taregetObjects list using array but it's removing only one item!

 

Code sample:

var my_item:TransformItem = t_manager.addItem(my_mc);
my_item.addEventListener(TransformEvent.SELECT, addToList);
function addToList(event:TransformEvent):void
{
    selectedArray = new Array;
    for (var t:int = 0; t<t_manager.selectedTargetObjects.length; t++)
    {
        selectedArray.push(t_manager.selectedTargetObjects[t]);
    }
    ///selectedArray = t_manager.selectedTargetObjects;
    ///selectedArray = t_manager.selectedItems;
}

//// Remove items from targetObjects array:

index = 0
for(var i:int = 0; i< selectedArray.length; i++)
 {
 ///////// some code here
 index++
 //trace(index) // output: 4
  if (index == selectedArray.length)
  {
  for (var t:int = 0; t < index; t++)
   {
     t_manager.removeItem(selectedArray[i]);
   }
  }
 }
it's removing one item only!

Share this post


Link to post
Share on other sites

Yep, it was just an error in the conditional logic you were using. You've got it solved now, right? Just making sure. 

  • Like 1

Share this post


Link to post
Share on other sites

Yes it's working thanks, I have another question plz can you explain me how move() method works? I want to move all the selected items by a button click I am using:

 

transform_tool.selectedTargetObjects.move(10,10,flase, false); this code doesn't work i am getting an error says "move is not a function" I tried so many codes but no one of them has worked! I can only move one selected item on x and y axis's using: transform_tool.selectedTargetObjects[0].x

what I am looking for is to move all the selectedItems depending on the dummyBox, is there any solution? Thanks.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.