I was a long time Flash Developer and really loved using Flash/Animate for building quick user interfaces for simple puzzles and games. I have been attempting to do something seemingly incredibly simple that just won't work.
1. Make a movieclip with some nested movieclips, each having an instance name
2. Drag the movieclip to the stage, and give it an instance name.
3. Use mainClip.setChildIndex(object1, mainClip.numChildren - 1) to bring object1 to the front of the displaylist.
the child index of object1 does move to the front, but it does not render in front. This is not very helpful!
I have noticed, however, that if I instantiate several movieclips from the library via code, I can change their order via setChildIndex and it works as expected. But any instance named objects nested in those movieclips cannot be rendered in a different order. (once again, their indexes can be changed, but they remain rendered at the same level)
This seems to be a pretty basic thing to be able to layout pieces and change their depth. For example, imagine a board with pieces where you can click one. It would come to the front of the displaylist so you can drag it across the canvas on top of other objects. Can we no longer layout assets visually?
Add a tick event and set the child index there so it gets set every frame (even if the index value doesn't actually change)
No, don't do that.
Nuthman, in HTML5 Canvas documents, any changes to timeline-controlled symbols get reverted when the timeline updates, and even single-frame timelines play continuously. So all you have to do is stop() your container clips.
Thanks for your response! Yes, there is only one frame in my timeline.
However, I had aready tried using stop(); on the container clip but it doesn't seem to make a difference. In fact, I just made a very simple new Animate file with only one MC and some code in it to show an example.
You can see that the depth is being changed, but the rendered depth does not change. and the piece is dragged.
Here is the FLA file:
Doh! Okay, I figured it out. I was putting the stop on the timeline of the container instance itself.
I added this.movieclip.stop(); to my main code and this actually worked. Whew, so simple yet it really got me.
Thanks a ton, ClayUUID!