Tuesday, October 13, 2009

Looping sound in AS3

Looping sounds is easy. Create your sound in the library. Give it a class name (we'll call ours SoundClip) and set it to export on the first frame. Then copy and paste this code:

var mySound:SoundClip= new SoundClip();
mySound.play(0,99);

The first number tells us where the sound should start, and the second number tells us how many times to loop it.

Monday, October 12, 2009

Transparent Gradient Mask in AS3

Creating a gradient mask in AS3 is pretty simple. Just copy and paste this code and you're good to go. First create your two movie clips, one for your mask, the other what's to be masked.

mcContent.cacheAsBitmap = true
mcMask.cacheAsBitmap = true
mcContent.mask = mcMask

There, just like that, transparent gradient masking.