hi again.
I am trying to create a movie with a song playing in the background with 3 buttons - one to play, pause and to continue.
I found a tutorial in the flashkit.com website but am having trouble understanding it. My questions are in brackets < >
Thanks you so much for helping.
Here goes:
First of all - import a sound - via rightclicking on the sound in the library - choose ‘linkage’.
Choose to ‘export this symbol’, and give it a name you will be able to identify it by - in this case ‘jinglebells’.
On the movies first keyframe we will instantiate a sound object, attach your sound to that object, and tell the sound to play.
here goes:
s = new Sound();
s.attachSound(“jinglebells”);
s.start();
< first question: where do i paste this code? right click, action…then where?>
Now that didn’t hurt one bit! If you test your movie now - you should have music playing.
Now for the hairy part.
We want the music to continue playing from the position we pressed pause - so we have to time our sound.
For this we will use the good old Date() object and place it in a function for easy access.
In the first keyframe continue the script by inserting the following before s.start().
i=1;
function timeme (){
now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
_root[“nowtime”+i] = (Number(hours)*3600)+(Number(minutes)*60)+seconds;
_root.newstarttime = _root[“nowtime”+i] - _root.nowtime1;
i++;
}
and after the s.start().
timeme();
< again…where do i paste this code? >
Now that was a strange brew - but in short the script times when we started the sound (nowtime1) and compares it to when we stopped the sound (nowtime+i). That info is converted to seconds, and is fed into our start button later.
Next make 2 buttons - one for pausing the sound, and one for un-pausing it.
The first button should have the following actionscript:
on(press){
s.stop();
timeme();
}
< err…where do i paste this code? >
The second button for unpausing the sound should have the following actionscript.
on(press){
s.stop();
s.start(_root.newstarttime);
}
The thing that makes this work is the variable ‘newstarttime’ it is fed into the un-pause button and is used for the built in ‘secondsOffset’ method which starts the sound x-seconds into the sound.
If you are experiencing trouble try importing another sound into your library.
Good luck!