|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
SitePoint Enthusiast
![]() Join Date: Feb 2007
Posts: 99
|
changing stacking order of display list
I have a series of mc's that I'm adding to the a display list of "theContainer". This is a "canvas" I'm using to drag mc's around on to make various pictures.
I've set up my code so I can click any mc in that list and make it "selected". I can then, with controls outside "theContainer", change the selected clip's scale or alpha, etc. I'd like to set up 2 buttons outside that display list so I can change the stacking order of those clips in "theContainer". So if I add clip "a" to the display list, then add clip "b" to the display list, then add "c" and "d" and "e and "f" to it, I want to be able to move any of those clips forward or backward. How do I go about doing this? First I'd need to learn what the index is of the clip I want to move up or down in the display list. To do that I'd use getChildIndex(clip). When i use a button outside the display list container i get this error: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display: isplayObjectContainer/getChildIndex()That's my problem, I can't know what the index is, or how to get a property to find it. I'm looking for a way to "get the clip's index" then to "make the index, the current index + 1", to move it up in the display list. "setChildrenIndex( dispObj, index ) would be nice if I could know what the index was and then add +1 to it like this: setChildIndex(clip, current index + 1); But I'm stuck with the error. Does anyone know what I'm doing wrong, or what I need to do? Thanks. R |
|
|
|
|
|
#2 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Apr 2004
Location: UK
Posts: 2,266
|
Whats the error you're getting ? The method (setChildIndex) is correct.
|
|
|
|
|
|
#3 |
|
SitePoint Enthusiast
![]() Join Date: Feb 2007
Posts: 99
|
the error was : 2025 The supplied DisplayObject must be a child of the caller.
I've figured this out (with help). final code was: var clipLevel:int; moveUp_btn.addEventListener(MouseEvent.CLICK, moveClipUp); function moveClipUp(e:MouseEvent):void{ clipLevel = select.parent.getChildIndex(select); c1.setChildIndex(select, clipLevel + 1); } I needed to put: "select.parent." in front of "select.parent.getChildIndex(select);" thanks for your response, R |
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 20:25.




isplayObjectContainer/getChildIndex()




Linear Mode
