Jump to content
Search Community

Deleting item bug [SOLVED]

P1000 test
Moderator Tag

Recommended Posts

I found that if you delete an item (using either the delete key, or the deleteSelection function), and then call selectAll, then you get a selection object where the items used to be - but any attempt to use it results in a load of exceptions being thrown. Further investigation showed that the deleted items were not getting removed from the _items array. I've created my own fix for this:


public function deleteSelection($e:Event = null):void {
		if (_enabled && _allowDelete) {
			var deletedItems:Array = [];
			var item:TransformItem;
			var j:int;
			for (var i:int = _selectedItems.length - 1; i > -1; i--) {
				item = _selectedItems[i];
				if (item.onPressDelete($e)) {
					//remove from _items array
					for( j = _items.length - 1; j > -1; j-- )
						if( _items[j] == item )
							_items.splice( j, 1 );
			if (deletedItems.length != 0) {
				dispatchEvent(new TransformEvent(TransformEvent.DELETE, deletedItems));


This seems to fix the issue!


Hope this helps someone!


Oh, and this is with the following version:



DATE: 3/6/2009

ACTIONSCRIPT VERSION: 3.0 (Requires Flash Player 9)

Link to comment
Share on other sites

Actually, I didn't remove the items from the _items Array because deleting an object just removes it from the stage, but it is entirely possible that you'd want to add it back to the stage. So deleting isn't the same as removing. But I did need to alter some deletion-related stuff in the class (which I just did). Please download it from the link you were provided when you purchased TransformManager and let me know if that works better for you.


By the way, where did you see the "selectAll()" method? I couldn't find it anywhere :) I assume you added that, right?

Link to comment
Share on other sites

Hmm - yes, I did - now I recall - selectAll was one of mine! Oops.. Basically it just passes the items array to selectItems. So, I guess this one is my bad, although it is the kind of thing I would have expected to be built in..

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