Spreads and layers ordering

Hi all,
i’m having a little “logic” problem.
I have some objects on the stage, and i want to bring them forward when touched with mouse. So i need a way to resort the spread of transforms etc in a way that the last thing i’ve touched is in front (like in a multitouch stack).
I’ve attached a simple patch i’ve made to try, but i’m sure i’m doing it wrong.
In my patch i can put an object in front of the others, but i cannot remember the previously selected object, so i cannot have a layes order that counts all what i’ve done before.
if someone has some hint, it’s very welcome

i’ve attached a patch as example

spread and layers ordering (13.1 kB)

this explains basically what you have to do… store the spread of the last frame with a FrameDelay and alter it in the current frame:

spreads_logic.v4p (16.4 kB)

but i am sure there is a contribution for this already… who knows it?

wow, thanks.
Yesterday, after a day of thinking, i’ve resolved, in another way, using store (spreads), and doing basically the same thing you are doing. but my patch needs a lot more nodes and seems lot more inefficent and elegant.
so i’ll use yours, thanks so much. very appreciated ;)