12.4. Exercises

  1. odify the script you completed in the fifth Try It Out example ("Finishing Off Slideshow Maker") so that the user is prompted for the duration of each slide. Make sure you handle invalid user input appropriately.

  2. The Piles of Pictures application works fine if the user does not try to do anything unusual, but it doesn't do a good job of taking into account exceptional circumstances. In particular, it doesn't consider the possibility that the user's iPhoto album contains no albums, or that the albums selected by the user are all empty.

    Modify the Piles of Pictures script so that it checks that the user selected at least one album, and that the selected albums are not all empty. If either of these circumstances arises, throw an error, and catch it again in the clicked handler. Display an alert panel if an error occurs. (Hint: Read about the alert panel class in the AppleScriptKit dictionary.)

  3. Piles of Pictures allows you to vary the scaling of the photos drawn in the poster, but the same scaling factor applies to all photos. The purpose of this exercise is to allow the user to randomly vary the scaling from one photo to the next, so that the poster ends up with a distribution of different sizes.

    Add a second slider to the Piles of Pictures user interface to allow the user to choose a variation factor from 0.0 to 1.0. Choose a random value for each photo from the range stipulated by the variation factor, and add it to the original scaling factor such that the photos each ...

Get Beginning Mac OS® X Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.