title: Managing event Listeners in Flash?
body: <p>I've been trying to make a flash 'game' of sorts, where a person on interactions with buttons can change the appearance of a figure in the centre.
  Such as press one button and they get a different kind of hat, press a different one and they can get a different kind of shirt or colour.</p>
  
  <p>I've laid out all the different kinds of combinations of the figure, and laid out the essential buttons.</p>
  
  <p>What <strong>should</strong> happen is that each button on each combination will lead to a different individual frame. Such as <em>button_1</em> on <em>frame 1</em> would lead to <em>frame 12</em>, while <em>button_1</em> on <em>frame 2</em> would lead to <em>frame 42</em> instead.</p>
  
  <p>The problem I'm having, which I believe is due to stacking eventlisteners, is that after going to <em>frame 2</em>, and then going back to <em>frame 1</em>, pressing <em>button 1</em> goes to <em>frame 42</em> instead of <em>frame 12</em>, or sometimes pressing <em>button 1</em> on <em>frame 2</em> leads to going to <em>frame 12</em> instead.</p>
  
  <p>I'm trying to find a way in that the event functions of the buttons 'reset' on leaving the frame, allowing the events of the frame you end up on to the the events that the buttons use.</p>
  
  <p>Here is a snippet of the code I am using on frame 2:</p>
  
  <pre><code>    button_20.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_19);
  
      function fl_ClickToGoToAndStopAtFrame_19(event:MouseEvent):void
      {
  
          gotoAndStop(322);
  
      }
  </code></pre>
  
  <p>And then on frame 3 the code for the button is:</p>
  
  <pre><code>   button_20.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_33);
  
      function fl_ClickToGoToAndStopAtFrame_33(event:MouseEvent):void
  
      {
  
      gotoAndStop(323);
  
      }
  </code></pre>
  
  <p>Could anyone help out with what I should do or if there's a more efficient method I could use?</p>
  
  <p>Thanks.</p>