Could somebody give a hand with this? Playing music all over flash website

ivanmax

New Member
Hi everybody!

First of all, many thanks for the other times you have helped me.

Would anybody be able to give a hand with this? I am creating a website in flash. I´ve a menu with "about us", "downloads", "photos", "facebook" and "contact". The think is that I want a song to play all over the flash movie, without mattering where the website user is. Can I do that somehow? I would like to have all the above mentioned pages in the same movie.

Please let me know if I am not explaining myself properly.

Regards and many thanks,

Iván
 

Mug

New Member
First off a lot of people don't like having music playing when you enter a site. I think the exception to the rule is when you visit a movie trailer type site where it is expected. I have multiple tabs open when I use the web so having music playing on one of them would drive me crazy. If you still want to include it then there are a number of ways to do it. It depends how your flash file has been set up but one way to do it would be:

have a frame for each section on your site (each section has it's own layer) then on the top most layer have a frame that spans the whole timeline (call it AS). Then on frame one put:

audioFile = new Sound (soundLoader);
audioFile.loadSound("yourmp3.mp3", true);

You should put some buttons on the page to stop the audio as well.

It has been a while since I did any AS so don't shoot me if this doesn't work.
 

bcee

New Member
If you are not loading new pages when the user navigates to another page you will be fine with the simple script as mentioned above.

Here is a simple one I had laying around from years ago:
Code:
var url:String = (_root._url.indexOf("http://") == -1) ? "sample.mp3" : _root.sound_url;
var snd:Sound = new Sound();
var snd_playing:Boolean = false;

function pauseSound():Void {
	if(!snd_playing) {
		playSound();
		return;
	}
	snd.stop();
	snd_playing = false;
	play_mc._visible = true;
	pause_mc._visible = false;
}

function playSound():Void {
	if(snd_playing) {
		pauseSound();
		return;
	}
	snd.loadSound(url);
	snd.onLoad = function(d) {
		this.start();
		snd_playing = true;
	}
	play_mc._visible = false;
	pause_mc._visible = true;
}

function init():Void {
	play_mc._visible = true;
	pause_mc._visible = false;
}

init();

play_mc.onRelease = pause_mc.onRelease = playSound;
 

ivanmax

New Member
Thanks!!

Many thanks! It is a site for a band, so I think music will be allright. Anyway I plan to put a "switch off music" button.

Again, lot´s of thanks to all of you.
 
Top