Ever since I upgraded to Yosemite, Applescripts that use delays have stopped working.  How can I fix this?

Here's the world's simplest Applescript, for the sake of an easy example:

set volume output volume 0
delay 5
set volume output volume 20
delay 5
set volume output volume 0
delay 5
set volume output volume 20
delay 5
set volume output volume 0
delay 5
set volume output volume 20
delay 5
set volume output volume 0


That should take 30 seconds to complete.  If I run it in Script Editor (formerly Applescript Editor) it takes 30 seconds to complete.  But if I save this script as an app, when I launch the app, the delays are ignored and the app takes a fraction of a second to complete.

How can I force Applescript to delay for a specified amount of time before moving on to the next step?  Is this a Yosemite glitch?  Is there a reliable workaround?


Question: Understanding the static keyword
Answer: Here's Joshua Bloch's way of explaining it, which I find brilliant like most of what he says (yes I'm a Joshua Bloch fan boy :) ). This is quoted from memory.

Imagine that a class is the equivalent of a blue-print for a house. Image then that a house is to the blueprint as an instance of the class is for the class. You can have one class (blue-print) and multiple instances (houses) created from it.

Now common sense dictates that most of the functions/behaviors that a house (instance) can have/do, even though they are declared in the blue-print, cannot be used until an actual house (instance) is made out of that blue-print (class). Like, your blue print might contain in it the place where the light switches and the light bulbs should go, but you have no way of making those work on the blue-print, you have to actually build the house in order to be able to switch the light switch on and off and have certain light bulbs go on and off.

However, you might have some behavior that is applicable to the blue-print directly, and which you could use/access directly on the blue print without needing to make an actual house out of that blue print. Imagine that your blue-print has a button that, upon pressing, will display the footprint of the house contained in that blue print (by calculating all the lengths of the walls and such). Obviously you COULD build a house first, then go around measuring its footprint, but you can do this with he blue-print alone, so it would be more helpful to have this behavior implemented in the blue-print. Such a blue-print embedded button that calculates the footprint of the house is the equivalent of having a static function in a class.