# Variabel value doesn't get stored

**URL:** https://forum.kirupa.com/t/variabel-value-doesnt-get-stored/315644
**Category:** flash
**Created:** [October 31, 2010, 7:16pm UTC](https://forum.kirupa.com/t/variabel-value-doesnt-get-stored/315644 "2010-10-31T19:16:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tomii01](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tomii01](https://forum.kirupa.com/u/tomii01)
#### Post date: [October 31, 2010, 7:16pm UTC](https://forum.kirupa.com/t/variabel-value-doesnt-get-stored/315644/1 "2010-10-31T19:16:42Z")

</div>

Hi!

I’m making a small animation with clickable elements for a friend and I’m having some problems.

The “inv” variable is set to 0 from the beginning, and when it changes to 1, a movieclip named “key” is supposed to show up.  
Somehow I can’t seem to be able to do this. First I tried to set it on various locations on the timeline - that didn’t work. Then I tried to do it directly into the event listener - that didn’t work either. What am I doing wrong? Here’s the code that goes into the first frame:

```auto

//stop film
stop();

//key
var inv:Number = 0;

if (inv == 0) {
key.visible = false;
}
	else {
	key.visible = true;
	}

knob.addEventListener(MouseEvent.MOUSE_UP, onDoor, false, 0, true);
function onDoor (e:MouseEvent):void {
	gotoAndPlay("smallRoom");
	inv ++;
}

badKnob.addEventListener(MouseEvent.MOUSE_UP, onBadDoor, false, 0, true);
function onBadDoor (e:MouseEvent):void {
	gotoAndPlay("badDoor");
	
}

trace(inv);

```
