-
Controlling sound loops with actionscript...
I've been working with three sound loops in Flash (my first time working with sound) and placing them on frames doesn't seem to be a completely accurate way to make sure they start straight after each other.
So I'd like to play the first sound once, then play the second loop straight after that one, and have it repeat 4 times, then on the 4th repeat, I'd like it to fade out in the last 5 seconds (it's a 22 second loop) and then, as soon as that's finished, play the third loop and repeat 4 times, too, then go back to the begining.
Can this be done with actionscript?
Thanks.
-
one approach is to use Flash 6+ onSoundComplete event, which can execute AS when a sound finishes playing. You might test this out first to make sure the transitions between sounds are seamless. If so you can work on the fade out.
Code:
firstloop = new Sound(target path to a movie clip);
firstloop.attachSound("linkageID");
// create sound objects and attach sounds
// for the other two loops
// play second loop 4 times after first loop
firstloop.onSoundComplete = function() {secondloop.start(0,4);
// play thirdloop 4 times after second loop
secondloop.onSoundComplete = function(){thirdloop.start(0,4);}
// restart sequence after 3rd loop
thirdloop.onSoundComplete = function() {firstloop.start();}
firstloop.start(); // start the sequence
-
Thanks for your reply, hp3.
So, forgive me, but should I create movie clips for each sound and put the sounds within the movie clips? Or call up the sounds with actionscript in the movie clips?
And I guess I should give each sound loop the instances "firstloop", "secondloop" and "thirdloop"?
-
You will attach a sound from the library to a sound object using the attachSound() method.
loop1.attachSound("loop1");
Each sound object you create needs its own unique movieclip to be independant of the other sound objects.
Take a look at the Remixology #1-2 for more information on how to work with Sound objects.
http://www.sonify.org/home/feature/r...ogy/index.html
-
AS vs timeline
i have to create like 20 soundloops for a client. embedding the mp3 and looping it caused a tiny pause while it was "rewinding".
so i created a miniature mp3 loop player in flash mx, and now i still have the same problem.
funny thing is, the loop player uses actionscript to load an mp3 that's added as a parameter.
(player.swf?url=02.mp3)
now, if i import the file into the flash movie and set the sound attributes to "loop X times", there is no "hickup" between the loops.
could it be something with the mysound.onSoundComplete thing?
i also tried reading the end of the file and restarting the sound
if mysound.position = mysound.duration { mysound.start()}
but it also lags during the loop.
any help on this? i don't want to create 20 different soundplayers that need to be re-encoded when the mp3 is changed.
thanks.
-
usually it is very difficult to acheive seamless looping with mp3.
1) mp3 encoders add a bit of silence at the beginning or end of a sound. Flash wraps loop points around the sound data including the silence. During playback the silence causes a gap in the loop.
2) onSoundComplete may also introduce some latency, though I havent thoroughly tested this.
If your goal is to provide a loop audition player using Flash, one option is to duplicate the loop 4-5 times in an audio editor, save as a single longer length mp3 and then stream the mp3. This avoids the problems flash has with looping mp3s.
-
i thought of the issue with silence and mp3.
but the fact is, that when i drag the mp3 from my library to the stage and set "event" and "loop 999", it plays without problems. no hickups etc.
so the mp3 is actually ok.
creating a longer mp3 loop will only delay the recurrence of the hickup.
i guess my only option is to create 20 seperate SWFs, import each mp3 into it's respective swf and set the loop there.
thanks anyways,
daniel
EDIT
i'm a dumbass. the working loop was with an imported AIFF file. so i guess there really is an mp3-silence-at-the-end issue. i'll give mp3trim a try. i'd like to be able to use the player with whatever number of mp3s the client will give me.
cool. thanks for the link (in your signature).
Last edited by D-Meister; 09-08-2004 at 11:51 AM.
-
I read this thread and said to myself "EUREKA!!"
Alas, I only have Flash 5....
And the onSoundComplete isn't a factor yet.
Is there a way to complete this process in Flash 5
I have 2 loops "Organ1" and "Organ2". "Organ1" is just the intro to the tune and then I want "Organ2" to loop infinately afterwards.
If you were me, you'd be home by now
-
For flash 5 compatible sequencing, you will need to use a loop mixing technique described in FAQ #16.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|