PDA

View Full Version : Simple If/then help



Meridian
July 6th, 2003, 04:37 PM
I'm trying to write an if then statement that will loop back to frame 1 once the next frame it hits is higher than 5. For some reason it doesn't work and I could easily go to frame six and add a go to and play but, I'd like to learn what's wrong instead of doing it the easy way. :)

on (release) {
if (_root.player_currentframe > 5) {
gotoAndPlay(1);
} else {
_root.player.nextFrame();
}
}


Mer

claudio
July 6th, 2003, 04:44 PM
Replace your code for this one: on (release) {
if (_root.player._currentframe>5) {
_root.player.gotoAndPlay(1);
} else {
_root.player.nextFrame();
}
}
I assumed you wanted your player movie clip to go back to freame 1. And you missed a dot before _currentframe.

Meridian
July 6th, 2003, 05:02 PM
hmm that didn't work it just sits there when it get's to frame 5... wich is the same problem I was having.

claudio
July 6th, 2003, 05:09 PM
Post the fla :)

Meridian
July 6th, 2003, 05:12 PM
Here ya go. The actions are on the mp3 player buttons, and they are controlling the main timeline in the player movieclip.

Hope that makes sence.

kode
July 6th, 2003, 05:19 PM
on (release) {
var frame = _root.player._currentframe;
_root.player.gotoAndStop(frame>=5 ? 1 : frame+1);
}

claudio
July 6th, 2003, 05:23 PM
Of course it wont work. Your player movie clip has exactly 5 frames, so the statement if currentframe>5 will never be true.
Change for this:on (release) {
if (_root.player._currentframe==5) {
_root.player.gotoAndPlay(1);
} else {
_root.player.nextFrame();
}
}

claudio
July 6th, 2003, 05:24 PM
Kax was faster :P

kode
July 6th, 2003, 05:24 PM
too late buddy. :P

Meridian
July 6th, 2003, 05:34 PM
Sheesh, I swear I did it the way you posted the code the 2nd time and it didn't work.. :(

Thanks for your help guys. :)

kode
July 6th, 2003, 05:35 PM
;)

claudio
July 6th, 2003, 05:35 PM
You're welcome :)

claudio
July 6th, 2003, 05:36 PM
Dam n Kax is a fast typer!
:P

kode
July 6th, 2003, 05:37 PM
:P

nah... i'm just bored. :-\

Meridian
July 6th, 2003, 05:40 PM
Since your both reading this thread and the file is posted. Either of you feel like taking a look at how I might go about getting my counter working to show the duration of the song?