Share Posted March 21, 2010 Hi I have a couple of controls that utilitze the moveSelectionDepthUp() & moveSelectionDepthDown() methods but I haven't been able to find a built-in function to get an accurate depth of the items on the board t a given moment. Sorry if this has been covered before but I searched the forums and documentation and couldn't really find a definitive answer. the getChildIndex() of the targetObjects seems to be off. Any suggestions? Link to comment Share on other sites More sharing options...
Share Posted March 22, 2010 I'm confused - you're saying Flash is incorrectly reporting the getChildIndex() of your DisplayObjects? Why do you think it's off? That's definitely the best way to determine the index of an object. Link to comment Share on other sites More sharing options...
Author Share Posted March 22, 2010 Yes but I thought it was related to this post that found where you mentioned that two sprites are added to the container: viewtopic.php?f=3&t=167&p=3545&hilit=depth#p627 I know that was an old post so Is that no longer the case or am I misunderstanding? Not sure if it matters but I'm using FlexTransformManager so I don't know if it adds UIComponents instead of Sprites Link to comment Share on other sites More sharing options...
Share Posted March 22, 2010 Yes, that post still applies. It does indeed add the __dummyBox_mc and __selection_mc as mentioned in that post. That won't make getChildIndex() report incorrectly, though. If you're still running into trouble, could you post a sample Flex project or FLA that demonstrates the specific issue you're wrestling with? It's always helpful to see your code and what context TransformManager is being used in. Link to comment Share on other sites More sharing options...
Author Share Posted March 22, 2010 I basically tried using the code form the forum post I linked to, but the sort order still seems to be off. private function bringForward():void { flexTransformManager.moveSelectionDepthUp(); sortBoard(); } private function sendBackward():void { flexTransformManager.moveSelectionDepthDown(); sortBoard(); } private function sortBoard():void { var clips_array:Array = flexTransformManager.targetObjects; var newArray:Array = []; for (var i : int = 0; i < clips_array.length; i++) { clips_array[i].vo.itemDepth = i; trace(i, flexTransformManager.getChildIndex(clips_array[i])); newArray.push({depth: flexTransformManager.getChildIndex(clips_array[i]), item:clips_array[i]}); } newArray.sortOn("depth", Array.NUMERIC); var arrangedArray:Array = []; for (var j:uint = 0; j < newArray.length; j++) { arrangedArray.push(newArray[j].item); } //Objects are still not in the correct order in arrangedArray; } Link to comment Share on other sites More sharing options...
Share Posted March 22, 2010 It would be super helpful if you posted a very specific example (Flex project or FLA) that demonstrates the problem. Not sure what "seems to be off" means specifically, where or how you're calling the methods, what values you're expecting in what context, etc. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now