Skip to content

Tag: Flash

How to put a sound on your website?

I use flash to achieve this. Create a new flash file with AS3. Create two buttons which will be placed one above the other. The stop button instance is called xstop and the play button instance is called xplay.

And this is the code:

//think of the soundchannel as a speaker system and the sound as an mp3 player
var soundChannel:SoundChannel = new SoundChannel();
var sound:Sound = new Sound(new URLRequest("http://www.kavdesign.net/sites/stgeorge/birds1.mp3"));

xstop.addEventListener(MouseEvent.CLICK, clickStop);
xplay.addEventListener(MouseEvent.CLICK, clickPlay);

playMusic();

function clickPlay(evt:MouseEvent) {
	playMusic();
}

function clickStop(evt:MouseEvent) {
		soundChannel.stop();
		soundChannel.removeEventListener(Event.SOUND_COMPLETE, loopMusic);
		xstop.visible = false;
		xplay.visible = true;
}

function playMusic():void
	{
		 soundChannel = sound.play();
		 soundChannel.addEventListener(Event.SOUND_COMPLETE, loopMusic);
		 xstop.visible = true;
		 xplay.visible = false;
	}

function loopMusic(e:Event):void
	{
		 if (soundChannel != null)
		 {
			  soundChannel.removeEventListener(Event.SOUND_COMPLETE, loopMusic);
			  playMusic();
		 }
	}

How to add a link to open a site in the browser on a flash movie?

Create a button on the movie.
Give a name to the instance of the button with the name button.
Put this code on the first frame of your flash movie.

button.addEventListener(MouseEvent.CLICK, btn_function);
var button_request:URLRequest = new URLRequest("http://mysite.com");
function btn_function(event: MouseEvent)
{
navigateToURL(button_request, "_blank");
}