Splitting a shape

Hello, i am coding a application, its looking like splitter game, but i am trying to splitting a shape with pen tool, like this, http://img35.imageshack.us/img35/2088/splitting.png
i made it with masking main object, but its not working stable when i draw new shapes on main object and mask it again. i need idea to create this application or anyone see sample like this? Its realy made me sleepless
Thank you…