Chekign frame

i wanzt to make a code like:

if (_root.frame == (“frame name”)){
this.gotoAndPlay (1);
} else {
this.gotoAndPlay (2);
}