# Smart Function

**URL:** <https://forum.kirupa.com/t/smart-function/189974>\
**Category:** flash\
**Created:** [June 7, 2006, 5:24pm UTC](https://forum.kirupa.com/t/smart-function/189974 "2006-06-07T17:24:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sepu](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@sepu](https://forum.kirupa.com/u/sepu)\
**Post date:** [June 7, 2006, 5:24pm UTC](https://forum.kirupa.com/t/smart-function/189974/1 "2006-06-07T17:24:24Z")

</div>

hey guys I got a quick question … there is a way to tell flash … if certain button is press gotoAndPlay certain FrameLabel …  
I want to make that functionality inside of this function…  
I already tried make a different function for each button and it works but Im pretty sure has to be a way to make all in the same function ?

anyway here is the function :

```auto
function goBackWards():Void { 
   this.onEnterFrame = function ():Void { 
      if (_currentframe <= _totalframes) { 
         prevFrame(); 
      } 
      if (_currentframe == 1) { 
         _root.gotoAndStop("home"); 
         delete this.onEnterFrame; 
      } 
   }; 
}

```

so this works when I say to my home btn this :

```auto
home.onRelease = function ():Void { 
    unloadMovieNum(2); 
    goBackWards(); 
};

```

so this goes to the frame label “home”

but how about if I want to my button Contact using the same function go to another FrameLabel and Play that MC … like my frame Label “M2”

my btn will be like

```auto
contact.onRelease = function ():Void { 
     unloadMovie(2); 
    goBackWards(); 
}

```

but the thing is how the same function can realise when I press this btn (Contact) and play that Framelabel that in this case will be “M2”  
Im thinking that it might be a conditional ? just Im not 100% sure? any help or hint would be greatly appreciated

thanks.
