PDA

View Full Version : play, pause, stop



nobody
March 15th, 2003, 08:48 PM
Hi, this is probably a dumb question as always, and I did search for it this time, but couldn't find what i was looking for

I took the tutorial on playing a sound file, but I want to know how to pause it, and stop it, eventually i want to do next and previous song buttons, but im not worried about those 2 for now.

This is the code I have
on (release) {
Finchsound = new Sound(this);
Finchsound.attachSound("Finch3");
Finchsound.start(0, 99);
}

Finchsound.pause doesnt exist, so what would i use as an alternative, and also finchsound.stop didnt work

finally, if you click play multiple times it just plays the song again, so you have a ton of overlapping songs.

any help would be great

thanks a lot

kode
March 15th, 2003, 09:11 PM
you can use a variable. something like


// create the variable in the timeline
status = "stopped";
// play button
on (release) {
if (status == "stopped") {
Finchsound = new Sound(this);
Finchsound.attachSound("Finch3");
Finchsound.start(0, 99);
status = "playing";
} else if (status == "paused") {
Finchsound.start(pausedat, 99);
status = "playing";
}
}
// pause button
on (release) {
if (status == "playing") {
pausedat = Finchsound.position;
status = "paused";
}
}
// stop button
on (release) {
if (status == "playing") {
Finchsound.stop();
status = "stopped";
}
}

i didn't test the script but at least that's the idea =)

nobody
March 15th, 2003, 09:20 PM
hey kax, thanks a lot for the reply
however.. i don't think i did it right
i would attatch a .fla but its way too big cuz i used a full song and i dont wanna search for a small loop
the song wont start and the output window produces
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: Statement block must be terminated by '}'
on (release) {

Scene=Scene 1, Layer=Layer 1, Frame=1: Line 10: Syntax error.
}

not entirely sure what to do about that
all i have on the main timeline is - status = "stopped";
do i need to do like an enterframe thing? if i do can u explain it because i am thoroughly confused

im sorry for all the dumb questions..

kode
March 15th, 2003, 09:27 PM
:stunned:
in theory .. the script seems to be fine :)

why don't you delete the sound from the library and attach your fla .. ??

nobody
March 15th, 2003, 09:28 PM
alright.. why didnt i think of that?

nobody
March 15th, 2003, 09:30 PM
maybe i should attatch the .fla.. duh

kode
March 15th, 2003, 09:31 PM
maybe i should attatch the .fla.. duh
good idea :P ;)

kode
March 15th, 2003, 09:51 PM
ok .. sorry for the delay :-\

i changed all the scripts to the timeline .. it's easier to edit/modify it that way :)

nobody
March 15th, 2003, 09:55 PM
no problem on the delay, i appreciate that u did that for me at all
thats really cool of u, the good thing is that most of the code makes sense to me.
I'm gonna fool around with it to see if i can make it play again when u push the pause button for a second time but I'm not worried about that too much.
thank u so much!

nobody
March 15th, 2003, 09:58 PM
woohoo!
i did it! on my own!
score
thanks again kax :love:

kode
March 15th, 2003, 10:03 PM
no problem =)

I'm gonna fool around with it to see if i can make it play again when u push the pause button for a second time but I'm not worried about that too much.
why am i doing all of your work!!? :P

pause_btn.onRelease = function() {
if (songstatus == "playing") {
pausedat = Finchsound.position/1000;
Finchsound.stop();
songstatus = "paused";
} else if (songstatus == "paused") {
Finchsound.start(pausedat, 99);
songstatus = "playing";
}
}

nobody
March 15th, 2003, 10:04 PM
u didnt read the post after that did you?
cuz i figured it out on my own:beam:
but thank u again, thats cleaner than mine

kode
March 15th, 2003, 10:04 PM
good for you! =)

note to kax. there's something called reload :P

kode
March 15th, 2003, 10:07 PM
by the way .. i just realized that i added a few useless lines in the play_btn

play_btn.onRelease = function() {
if (songstatus == "stopped") {
Finchsound = new Sound();
Finchsound.attachSound("Finch3");
Finchsound.start(0, 99);
songstatus = "playing";
} else if (songstatus == "paused") {
Finchsound.start(pausedat, 99);
songstatus = "playing";
}
}

nobody
March 15th, 2003, 10:09 PM
i realized that as well!
WOW!!
I might finally be gettin the hang of this stuff..
ok so i still cant make my own stuff for crap
but im startin to understand how stuff works

thank u!

kode
March 15th, 2003, 10:12 PM
i realized that as well!
WOW!!
I might finally be gettin the hang of this stuff..
finally :sigh:. it was about time :P ;) just kidding

nobody
March 15th, 2003, 10:15 PM
awwwww
how sweet
come on tho, ive only been doin AS for about a month now
and im an incredibly slow learner due to the fact that im really stupid
so i think im doin alright

kode
March 15th, 2003, 10:19 PM
and you think that i learnt everything i know in a month? :sigh:

i learn something new every day! and i can assure that i will never stop learning something each day :)

so you just keep practicing ;)

nobody
March 16th, 2003, 01:16 AM
Oh I will
I wanna be amazing like everyone here.. shh.. yah.. thats gonna happen

kode
March 16th, 2003, 06:23 AM
shh.. yah.. thats gonna happen
eventually .. :P

ps. you know i'm kidding again ;) =)

nobody
March 16th, 2003, 09:16 AM
lol
lets all mock the new flasher guy
no seriously
do
its funny:beam:

kode
March 16th, 2003, 10:28 PM
are you sure about that? you won't be able to stop me later .. think again ;)

by the way ..

Yo tengo un gato en mi pantalones.
:P :P

nobody
March 16th, 2003, 10:32 PM
I enjoy being mocked.. its amusing..
and yes, i do have a cat in my pants

a lot of people have noticed that.. it makes me feel speeeeshul:beam: