Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
chup

problem with forceSelectionToFront? (as2.0) [SOLVED]

Recommended Posts

Hi, i have this following code that add item dynamically to the stage. But it there is some problem with it.

 

For the 3rd item i insert and move, it will remove the 1st item

for the 6th item i insert and move, it will remove the 2nd item

for the 9th item i insert and move, it will remove the 3rd item

for the 12th item i insert and move, it will remove the 4th item

 

but the item will not be be remove if i just simple insert and not move the item. So i suspect the problem is with the "forceSelectionToFront" which kinda change the depth of the item and cause the problem.

 

here is my code

 

// transform manager
var manager_obj = new TransformManager({targetObjects:[], bounds:{xMin:-300, xMax:700, yMin:-300, yMax:650}, forceSelectionToFront:true, scaleFromCenter:true, allowDelete:true, constrainScale:true, lineColor:0xa23a3b, handleFillColor:0x888888, eventHandler:onAnyEvent});

//
// add item to stage
totalDesignItem = 1;
totalDesignCount = 0;
//
stageWidth = miniStage._width;
stageHeight = miniStage._height;
//
for (i=1; i<=totalDesignItem; i++) {
this.cpanel.panel2.elementMc["elementTn"+i].btn.onRelease = function() {
	totalDesignCount += 1;
	//
	id = this._parent._name.substr(9, 2);
	miniStage.itemHolder.attachMovie("element"+id,"stageElement"+totalDesignCount,totalDesignCount);
	//
	miniStage.itemHolder["stageElement"+totalDesignCount]._x = stageWidth/2;
	miniStage.itemHolder["stageElement"+totalDesignCount]._y = stageHeight/2;
	//
	// add item to transform manager
	manager_obj.addItem(miniStage.itemHolder["stageElement"+totalDesignCount]);
};
}

 

 

any idea where did i go wrong?

 

thanks in advance :)

Link to comment
Share on other sites

It's typically a bad idea to hard-code the depth levels like that because you're assuming there's nothing at that level even though there may be. Instead, you should use getNextHighestDepth() and let Flash tell you what's available. TransformManager adds some things to the stage (like the cursors).

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