AS3: Stop all sounds from playing

If you ever need to stop all the sounds playing in flash using ActionScript3, you can do so using the following method.

First include the SoundMixer class:

import flash.media.SoundMixer;

Then to stop the sounds call the stopAll method:

SoundMixer.stopAll();

SockAndAwe Google Gadget

After working with the SockAndAwe.com site for a little while now, I have written and submitted my first Google Gadget which displays the number of shoes thrown at George Bush via the internationally popular flash game.

To embed this gadget into your site you can use the following code:

Alternatively you can add this to your iGoogle homepage or customise this gadget to fit your site design.

Why not join in shoe throwing fun and see how many times you can hit Bush by playing the game at www.sockandawe.com.

CSS: Targeting Safari 3 only

Although Safari 3 tends to render layouts the same as the other leading popular browsers, it prefers to use it’s “aqua” button styling for standard sized form buttons.

One solution for this is to set a dimension (width or height) to the button.

To target Safari 3 in CSS you can use the following to add or override any existing attributes, such as the height of a button:

@media screen and (-webkit-min-device-pixel-ratio:0) {
	button {
		height: 40px;
	}
}

If required, multiple selectors can be added into a single block.

Flash AS3: Play sound from the library

In order to play a sound from the library you can use the following simple AS3 code:

var snd:Beep = new Beep();
snd.play();

You must also assign your sound clip a class name by right clicking the sound in the library and checking the export for ActionScript option. In the example above the class name was set to “Beep”.

The default base class  is set to “Sound”, allowing inheritance of methods from the Sound Class.