PDA

View Full Version : Carousel showing up beneath background elements!



katyjack
November 12th, 2009, 09:53 AM
I'm creating a carousel using AS3 based on the following code:
http://www.actionscript.org/forums/showthread.php3?t=154403

I've got several elements on the stage that I'd like to be behind the carousel but instead I can see that the carousel is showing up behind all the elements on the stage. Can anyone tell me why this might be happening and how I can fix it? Most annoying.

Thanks -

0L4F
November 12th, 2009, 10:25 AM
That's probably happening because those elements are added to the display list after the items from the caroussel.

You could try adding the caroussel to a holder clip:


var mItemHolder:MovieClip = new MovieClip();
addChild(mItemHolder);


and then, in your init function, do not


addChild(item);


but


mItemHolder.addChild(item);


Then you can make sure the caroussel is on top like this:


mItemHolder.setChildIndex(this.numChildren - 1);

katyjack
November 12th, 2009, 10:33 AM
That's probably happening because those elements are added to the display list after the items from the caroussel.

You could try adding the caroussel to a holder clip:

ActionScript Code:

var mItemHolder:MovieClip = new MovieClip();
addChild(mItemHolder);




and then, in your init function, do not

ActionScript Code:

addChild(item);




but

ActionScript Code:

mItemHolder.addChild(item);




Then you can make sure the caroussel is on top like this:

ActionScript Code:

mItemHolder.setChildIndex(this.numChildren - 1);




The elements are already on the stage -- could they still be added to the display list after the carousel? I'll try your tip though -- I still don't fully understand how things get added and when in AS3.

Thanks -

katyjack
November 12th, 2009, 10:55 AM
That worked - thanks. And it will be convenient to have the carousel in one movieclip for centering on the stage, etc.