title: Flash AS3 - Object not getting set to null
body: <p>I have menu system that I built in Flash that allows you to select an item and move it up or down.  If the object is removed from the menu, I want the selected item to be set to null, so it won't try to be moved anymore.</p>
  
  <p>I have a global (for the current movie clip timeline) variable:</p>
  
  <pre><code>var selectedPlaylistItem:MovieClip;
  </code></pre>
  
  <p>That stores which menu item is selected (menu items are just movie clips), and if that item is removed, I set the selected item to null:</p>
  
  <pre><code>function removeFromPlaylist(sender:playlist_content_item) {
      if(sender == selectedPlaylistItem) {
          //Not sure why this isn't working, but at some point I need to figure it out.
          selectedPlaylistItem = null;
          trace(selectedPlaylistItem);
  </code></pre>
  
  <p>That trace will show null without any issues, but in my next function that moves items up, after I have set it to null, it is still set to the object that it was before it was removed:</p>
  
  <pre><code>function playlistUp(sender:MovieClip) {
      trace(selectedPlaylistItem);
  </code></pre>
  
  <p>That trace will show the original object.</p>
  
  <p>Does anyone know why that wouldn't work?  Why wouldn't it just stay null after it was set that way?</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>UPDATE:</p>
  
  <p>So I tried this to see if I could figure out what's going on:</p>
  
  <pre><code>    this.selectedPlaylistItem = null;
      trace(selectedPlaylistItem);
      setTimeout(function() {trace(selectedPlaylistItem);}, 4000);
  </code></pre>
  
  <p>But when the trace happens 4 seconds later, it says it's still the selected object even though the trace right after shows it as null, and I've looked everywhere in the code, but there's nowhere it would be getting reset.</p>