Createjs index hack

Datetime:2016-08-22 23:08:15          Topic:          Share

This is a question and answer at the same time.

So during an 'onclick' event I've used createjs to

'addChild' so that the 'child' or 'displayObject'

is re - added to the canvas every time it's clicked.

I've done this so that the 'displayObject' (in this case a bitmap),

has a primery z-index, so it overlays all other children

of the canvas or the canvas container.

It seems a bit of a hack in that there doesn't seem an easy way

to arrange your z-index with javascript.

I haven't got the code in front of me but it's something like this;

-bit map created

stage.addChild(picture1);

function(event){'click'  -- bla bla

addChild(picture1)  }  ....So I'm adding 'picture1' during the 'event'.

when it's already added to the stage. So if you have a number

of images say 20, each time it's clicked, it becomes the top of the stack.

and the order 'addChild(picture"whatever")' is fired as many times as the user

wants. This might be a createjs hack rather than a canvas hack, as the canvas

is supposed to be continually redrawn. Any thoughts would be great and I'll

grab the code and post it when I get the chance. H