actionscript 3 - AS3 Custom Depth Control -


i trying create way of controlling movieclip depths, movieclip show above another, can set depth of movieclip number , displayed higher values above lower values.

i thinking of creating movieclipdepth class extends movieclip added property depth, and container class extends displayobjectcontainer all objects placed inside of.

the container class override addchild method update child display order when child added.

what need how reorder children according depth value?

as can read in comment below question, there several methods this.

but actually, asked "set depth of movieclip number" can't done in as3. if i'm correct, in as2, so...

... how ...

_root.createemptymovieclip("mc", -1000); 

or

_root.createemptymovieclip("mc1", 1); _root.createemptymovieclip("mc2", 10); 

worked, not work in as3. in as3 depth starts 0 , can't force displayobject sit on level not continous zero.

so depths' of 3 movieclips in container possible these values: 0, 1, 2.

depth can't negative number example.

now, if want build custom depth manager, can that, have consider these facts.

so say, create virtual depths.

so guess, override addchildat method example. @ moment, if give wrong number: negative, or higher number of children, flash give error:

rangeerror: error #2006: supplied index out of bounds. 

so mc.addchildat(newchild, -1000) gives arror.

but overriding method, make trick, store depths in array. store numbers , transform order needs of as3.

like pairing depths added children, sorting array depths, manage children according order.

if have more questions, feel free ask, hope gets closer solution.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -