How to protect my flash application?

Hello everybody. I am gonna to create a comercial application in flash ,and I am interesting how to protect my flash movie with php. I am a begginer in php , but if you help me , I am gonna go search on the web .

Is this idea good?
I think to create a php page where to put an InputText and to create a random generator serial code in php . The client buy the serial code from me ,and then copy his code in InputText.
if InputText == algorithm of key generator then (redirect) go to and play flash movie
else error.

Can you give me an exemple for this ? It this possible ? How can I redirect a visitor / client to right webpage?

Thx for helpful answers!