• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Lesson 28. Date Conversions > Preventing Your Movie from Running after a Certai...

Preventing Your Movie from Running after a Certain Date

You may want to place a limit on your finished program so a user cannot play it after a certain date. This may be an evaluation version of your software, for example, that you want the user to be able to use for only a certain number of days. To prevent your movie from running after a certain date, you need to compare the current date against the target date. You laid the groundwork for this action in the previous tasks.

1.
Open the Cast window and select cast member 1, which contains the movie script with the startMovie handler. Click the Script button to open the Script Editor.

You will be changing the startMovie handler so that it checks the current date and stops the movie if the expiration date has been reached.

2.
Modify the startMovie handler by adding the lines shown here in bold:

on startMovie   --Do every time the movie starts.
  member ("Today").text = the long date
                --Place the date in the Today text field.
                --Check to see if this software is current.
  expirationDate = date("19981125")
							--This is the last day the user can use the program.
							if the systemDate > expirationDate then
							halt
							end if
end

3.
Close the Script Editor and then play the movie.

The movie stops immediately, since the current date is past the expiration date. The user won't know why the movie stopped, though. You need to provide feedback to let the user know the reason the software does not run.

4.
Open the Script Editor again and modify the movie script as shown here in bold:

on startMovie   --Do every time the movie starts.
  member ("Today").text = the long date
                --Place the date in the Today text field.
                --Check to see if this software is current.
  expirationDate = date("19981125")
                --This is the last day the user can use the program.
  if the systemDate > expirationDate then
    alert "The demonstration period has expired."
    halt
  end if
end

The alert command causes a dialog box to appear with the text provided in the command. When the user clicks the OK button in the dialog box, the program terminates.

5.
Close the Script Editor and play the movie.

The notification appears, and the movie stops.


Figure .


Using this simple technique, you can prevent your movie from running past a certain date. By extending this same programming technique, you could also display a message telling the user where to buy a true version of your software. You could also display a message each time the user runs your movie, such as "You are on day 20 of your 30-day evaluation period."


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint