MX 2004 game

I want to make a game where moving the mouse tilts a cannon, so you can aim cannon balls at targets, but I wouldn’t have a clue how to do this. I’ve made a first-person shooter in Flash, but this is a completely different way of doing it as far as I’m aware. Can someone please post some code for the cannon, and also how do I get a certain number of balls to come out of it, which fall to the ground after a while?