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.
I have a global (for the current movie clip timeline) variable:
var selectedPlaylistItem:MovieClip;
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:
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);
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:
function playlistUp(sender:MovieClip) {
trace(selectedPlaylistItem);
That trace will show the original object.
Does anyone know why that wouldn't work? Why wouldn't it just stay null after it was set that way?
Thanks
UPDATE:
So I tried this to see if I could figure out what's going on:
this.selectedPlaylistItem = null;
trace(selectedPlaylistItem);
setTimeout(function() {trace(selectedPlaylistItem);}, 4000);
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.