how i can do a music infinite loop for background music?
Printable View
how i can do a music infinite loop for background music?
just set the loop to 9999 i think that should do the trick,
i dont think theres an option for an infinite loop
oioi
you can also put the music in a movie clip
it is 999 :)
where i put the 9999??
in properties? sound? actions? or where? :P
and.. for the movie clip
how i do make the sound loop using a movie clip?
click on Insert >>>
New Symbol >>> Behavior: movie clip
next add the music to keyframe1
in the movie clip
set the Sync to event
set the loop to 99 times
If you don't know how to set the loop and sync
then i suggest you read the help files.
Sorry to resurrect an old thread, but this is the one that came up in my google search, so I thought it'd be good to post a solution so anyone else who's trying to find the answer will have it.
Anyway, I came across this quick little trick that easily sets up an infinite loop without using any sort of 999 repeats (which can be problematic in long games or short loops, and just seems dangerous in general):
music1.start();
music1.onSoundComplete = function() {this.start();}
note that onSoundComplete does not guarantee a seemless loop.
I believe that starting with Flash 8 you could specifiy "infinite" loop in sound properties for sounds on the timeline, though this does not help the problem with infinite loop in sound object.
i just tried this and it seems to work. it uses the sound object
PHP Code:
song = new Sound();
song.loadSound("your.mp3", true);
onEnterFrame = function () {
pos = song.position/1000;
dur = song.duration/1000;
if (pos>=dur) {
song.start();
}
};
I just started flex a few days ago. I looked all over for a way how to loop background music. The only idea that I found worked was to put in the rediculously large # into the loop argument. Like so :
MySound.play(0, 999);
But I looked to the help files after still not satisfied~ In there I found SoundChannel. Used as so:
var channel : SoundChannel = MySound.play(0, 0);
You can catch the event when the song ends like so:
channel.addEventListener(Event.SOUND_COMPLETE, PlayAgain);
And here is how I handled that event:
private function PlayAgain(event : Event) : void
{
channel.stop(); //<---- this I added just in case
channel.removeEventListener(Event.SOUND_COMPLETE, PlayAgain);
channel = MySound.play(0, 0);
channel.addEventListener(Event.SOUND_COMPLETE, PlayAgain);
}
I had to declare the sound and the channel as members of the class for this to work due to scope and the inability to assign anything to the event.target. For some reason the sound will not loop if you just set the channel equal to the sound. It will play a second time but thats it! So I added another event listener to try an make it play again. Now I wasn't sure if the event listeners, if already set, stack in AS3. So as to not have thousands of the same event listener on this one channel I remove it just before reassigning the sound to the channel. I looped sounds past 6 times so i'm going to say this works well. I hope this helps.
I read from the AS3 Cookbook and the author said there is no way to make sound loop forever but there is a way to make sound plays for a very long time by using
The sound will play for approximately 70 years!Code:this.play(0, int.MAX_VALUE);
man that stinks so what i did was i made it start inside a movieclip and in the movieclip is 2 frames first one makes it start second stops it and when you press quit make it go to nextFrame(); for movieclip before it goes to another frame
I tried this, it worked. Thank you
If sound is external:
// if music file is in another url (not in the same folder as the *.swf file) use "http://yoursite.com/music.mp3" instead.PHP Code:
var music:Sound = new Sound()
music.load(new URLRequest("music.mp3"));
music.play(0, int.MAX_VALUE);
If sound is in library, with class name "music":
And i have a method to loop forever... you play it MAX_VALUE times, and add a listener to listen for the music to finishes, then play it it again MAX_VALUE times.PHP Code:
var music1:music = new music();
music1.play(0, int.MAX_VALUE);
I have not waited for hours to see if it really loops, but I've waited quite long and it keeps playing...PHP Code:
var music1:music = new music();
var chan:SoundChannel = new SoundChannel();
chan = music1.play(0, int.MAX_VALUE);
chan.addEventListener(Event.SOUND_COMPLETE, loop);
function loop(e:Event):void
{
chan = music1.play(0, int.MAX_VALUE);
}
Thanks a lot for trying to help me, I appreciate it.
Can you please tell me where should I put the code? in which scene or frame? to be honest I never never used scripts in swish, so I totally lost
Also, the sound is in Library, but, I don't understand what does the word 'class' refers to
Note: um using swishmax 4
Note: my file has so many scenes and I want it to play across all scenes
Thanks again
Sorry, the script is for flash as3. Swish doesn't support as3. Long time i don't use Swish so i can't help :(
Hi,
Perhaps here might help http://archives.swish-tutorials.com/...act=tut&id=102
Thanks a lot both of you.