PDA

View Full Version : Adding Flash background loop w/option to turn off


Eden
10-4-05, 10:38 PM
Hey everyone, I'm trying to place a small background loop on my page that you can turn off. I found this one http://www.flashkit.com/movies/Sound/Controls/Sound_pl-Photius_-8312/index.php which I have modified the look which I am happy with but I can't seem to get the sound working properly. The comment "Add music track to each of the first 4 frames and call those frames first to play" makes no sense to me whatsoever and I've tried emailing the maker but no response. The track I'm trying to add is 4 seconds long that I want to just keep looping unless the user turns off with the button and all I can get this thing to do is start but then it keeps adding on top of itself so it is not enjoyable to listen to (hope that made sense) and it will only stop after after clicking TWICE. Also I can't get this annoying click sound out of there.

The code Actions for Frame 1
status_btn.onPress = function() {
if (status_var == "ON") {
status_var = "OFF";
stopAllSounds();
stop();
} else {
status_var = "ON"
play();
};
};
I have tried adding the clip (which I've added to the library) to this code somehow but that didn't do anything. (didn't expect it to but was worth a shot)
There isn't anymore code in this file just layers (bar1, bar2, layer4, layer5, layer6, layer7, layer8, and button) but playing with those I've found it is just the bars :confused:

Sorry I can't really explain more than this I just need to figure out where to put the sound clip and would appreciate any help I can get. I have no experience with Flash at all (I'm using Flash MX btw). If you need more info let me know. If you know of a nicer, easier one to use that would be great also ;)

Croc Hunter
10-5-05, 05:47 AM
I haven't looked at your link yet but why not just stick the code in the html page.

<embed src="http://www.yoursite.com/music/musicfile.wav" autostart="true" loop="true" hidden="true">

Then it will play even if flash is disabled in your visitors browser.
If you want visitor to be able to stop the music use the following.

<embed src="http://www.yoursite.com/music/musicfile.wav" autostart="true" loop="true" width="4" height="4">

Eden
10-5-05, 08:59 AM
Thanks for your ideas Croc Hunter. The reason I am mainly looking at is I'm trying to go for the jumping bars thing (don't know what it's actually called which is why I'm having a hard time finding tutorials). I've got this one to look and match my site really well I just need to get the sound working. I have used your method in the past and if I can't find a solution for this I will probably go that route again although I'd rather not :rolleyes:

An example of what I'm REALLY after can be found here (just the moving bars flash is all I want to do, nothing else, and of course I have my own clip LOL) http://www.4templates.com/view/search=%3D%3DAecuEtyErquYrM1KlKpkKLIVlsuYrM0KlMEEt 5WpUuJWSyZkZKg4ZgVKBiyCrUK7Urs88LKliVya-gIQapmYJlWUqAFIRgau6MtyAImi5KZdt1CAQjt0hH/2/DZ0006RD
If I knew what exactly what that was called I'd have better luck too. My searches take me way off track...for all I get is how to make an mp3 flash player, where to buy extremely overpriced flash templates, or how to build an equalizer. While the latter is similar I'm not enough trained in flash to make any sense of it at all. The first link I gave in my last post was really easy to customise the look but getting any sound to work is not working at all and is getting on my nerves :o

Arun
10-7-05, 09:01 AM
Export a sound file to your current project's library. Give it a unique id like "bgscore". Use the code below to make it loop. You can place this code in a layer and call it soundlopp action or something.

mySound = new Sound();
mySound.attachSound("bgscore");
mySound.start("0", "999");

Now make the buttons that togle to on an off when pressed. Make two buttons for play and pause. Place the pause button in a layer above the play button.

Give the pause button the instance name pauseBTN add the below action script to button instance pauseBTN

on (release) {
mySound.stop();
playing = false;
playBTN._visible = true;
pauseBTN._visible = false;
}

Give the play button the instance name playBTN. And add the below code to that instance of play button

on (release) {
if (playing != true) {
mySound.start(0, 999);
playing = true;
playBTN._visible = false;
pauseBTN._visible = true;
}
}

Thatz it. Hope that helps..

Arun
10-7-05, 09:03 AM
Don't care the syntax highlighting, wrongly used the bb code for php :P

acidfire
10-18-05, 04:56 PM
That helped me a lot of searching for a toggle button. Thanks Arun..... :)