From my previous post, animation.Float, I had the basic example of the animation class that I wrote to simulate dandelion seeds floating in the wind. Well I had some free time this weekend and decided to keep my AS3 skills sharped and went on to add interactivity! Depending on the location of your mouse will vary on the speed of the wind blowing the seeds around. Farther away you go from the middle the faster the wind gets. The interactivity is also directional and when you click on one of the seeds they disappear.
The Float class was one of the very first classes that I wrote on my own. Pretty much after I got done reading a book about OOP in AS2, I started this class. Looking back now, it was pretty rough. To add in the interactivity and to port the class over to AS3, I pretty much gutted the whole thing and started new, but it is neat to see that I have come a long way in such a short time.
Now the seeds are in a new Dandelion class that extends Float. Float contains a wind object which is shared among the other instances of dandelion seeds (kind of like a singleton, not really fond of them personally, but that is a different post). After that is was simple to add in the required mouse detection class and update the wind velocity based on the mouse position.
There are still a few bugs left, if you are in FireFox switch to another tab and then come back. Also I want to enforce the wind velocities a little better in case the mouse position is too extreme. To enhance it I want to make it 3D by splitting the picture into layers and having the seeds go between the tree. The 3d would also have the smaller seeds be removed from the stage earlier to make it look like it landed in the background of the image.
Licensed under Creative Commons, so feel free to use them in your project and if you do please let me know.