Quazi's method would work just as fast in C2 except there is no way in C2 to save the result of an effect to use on the next frame.
Other than that the logic to move the pixels is simple.
* if the area is free below a pixel is free move it down.
* if the area is not free try to move down left or down right if those areas are free.
Here is a demonstration using my canvas plugin. As you can see it is very slow. For this sort of thing you'll want a method a lot faster, but for that you'll have to delve into some javascript.
https://dl.dropboxusercontent.com/u/5426011/examples17/sand.capx