I made this example a while ago, added some comments for you:
But like Kyatric said; the problem might need to be explained in a bit more detail. I'm not really sure what you need exactly, but I hope my example is similar enough to be helpful. If not you should definitely do as Kyatric suggested and post a .capx yourself.
Develop games in your browser. Powerful, performant & highly capable.
Wow, Nimtrix. A little excessive on the coding, but very impressive results.