Because the objects that might want to block the sunrays exist on different layers, I run the collision check in a fastloop. The fastloop moves the collision detector through each of the relevant layers one-by-one, each time checking to see if it hits one of my background objects (event #3182). It also checks to see if it hits one of my foreground platforms (event #3181), though it only needs to do this once, as they are all on a single layer (layer 30).
If anything is found to collide during this fastloop, a flag is set, which triggers event #3187 or #3189, where the alpha is modified, in much the same way that you do it. (I use alpha blending coefficient instead of semi-transparency, as that's what I'm used to). The windyMedium/wavyFast/gentleSlow things are just some extra randomised/sinewave-based numbers that I calculate elsewhere in my code; they just add a little subtle variation to the way the sunrays behave.