This example was created to show off the transparent window feature in SWF Studio by having an animated critter chase your mouse cursor around the screen.

The most obvious way to do this would have been to create a transparent window the size of the desktop. If you've ever created a large transparent window you've already discovered that the bigger they are, the harder they are on the CPU. A full screen transparent window would have been just too slow.

To get the effect I wanted without killing the CPU, I really needed to use a smaller window. In fact I needed two windows, one for the critter doing the chasing and one to highlight the position of the mouse cursor. But SWF Studio doesn't support multiple windows (yet) so I had to improvise.

By using a SWF Studio splash screen and the Splash.setPosition and Splash.setVisible methods, I was able to get the effect I wanted.

When you start the example a ladybug appears in the bottom right corner of the desktop and immediately starts moving toward your mouse cursor. This ladybug is the main application window. When the ladybug catches the cursor, the cursor will be transported to a random location on the desktop. After the cursor has been moved a small bulls-eye style animation appears at the mouse cursors new position to help you spot it. The animation disappears automatically after a couple of seconds or as soon as you move the mouse cursor. This animation is displayed using the splash screen.

So instead of moving a movie clip around a very large stage we're moving two very small windows around the desktop in response to changes in the position of the mouse cursor that we read using Mouse.getPosition and change using Mouse.setPosition.

All of the commented code is in (ActionScript 3) except for the bit that animates the bulls-eye (in bullseye.fla) and the code initializes the Ladybug class and starts the whole process. The initialization code (shown below) is on the timline in ladybug.fla. All it does is wait until the stage is ready and then it creates an instance of the Ladybug class and passes it a reference of the movie clip it should animate (the ladybug).addEventListener(Event.ADDED_TO_STAGE, init);

function init(e:Event=null):void
   var bug = new Ladybug(bug_mc);

Download your FREE trial version of SWF Studio today. 4.7 MB

NOTE: This examples requires SWF Studio 3.8 build 333