IF Else Statements?

Hello people,
I have 5 Videos, with a transition video clip between each one.

Basically I want to write some script for a button that says “If Video1 is on its last frame (Reached its end), gotoAndPlay Transition to Video2”. Then Video2 plays and loops, just like Video1 did.

I’d like to repeat this for all five videos.

Does anyone know the easiest way to achieve this? I’m a beginner in AS.

Thanks in advance