Go Back   SitePoint Forums > Forum Index > Design Your Site > Flash and Actionscript
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Nov 4, 2009, 14:10   #1
rickarooni
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
rickarooni is offline   Reply With Quote
Old Nov 5, 2009, 05:22   #2
jim_morrison3
SitePoint Wizard
 
jim_morrison3's Avatar
 
Join Date: Apr 2004
Location: UK
Posts: 2,266
Whats the error you're getting ? The method (setChildIndex) is correct.
jim_morrison3 is offline   Reply With Quote
Old Nov 5, 2009, 08:21   #3
rickarooni
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
rickarooni is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 20:25.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved