# Variable monitoring from outside class

**URL:** https://forum.kirupa.com/t/variable-monitoring-from-outside-class/324156
**Category:** flash
**Created:** [August 5, 2011, 6:29am UTC](https://forum.kirupa.com/t/variable-monitoring-from-outside-class/324156 "2011-08-05T06:29:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Icarium](https://avatars.discourse-cdn.com/v4/letter/i/7feea3/32.png) [@Icarium](https://forum.kirupa.com/u/Icarium)
#### Post date: [August 5, 2011, 6:29am UTC](https://forum.kirupa.com/t/variable-monitoring-from-outside-class/324156/1 "2011-08-05T06:29:18Z")

</div>

Hello,  
I am attempting to make a simple class that I use to debug some of my code at runtime. I use a function in my debug class to pass a variable from another class that I want to monitor in realtime.  
For simplicity sake I am only passing Stings at the moment. I can pass the variable that I want successfully but I am stumpted as to how I to get my DebugClass to monitor that variable in realtime.  
Since the variable is being altered in another class, what would I needto do to have the debugClass monitor that variable without having to call a new function everytime the varible changes, which could be 300+ times a minute.

This is the current method I use to add the variable to my displayList:

protected function addDebugData(stringToAdd:String):void{  
var debugText1:TextField = new TextField();  
debugText1.border = true;  
debugText1.width = 300;  
debugText1.text = stringToAdd;  
debugText1.y = 20;  
panel.addChild(debugText1);  
}

The problem with this method is that it is a one time display method. The current value passed is displayed, but that is it. My Class has no knowledge of any changes made to the parent variable. I have a method to update my panel that displays the variable(s) I have Passed, but those variable are still whatever I initialy passed via my  
method. I am likely missing something simple in scoping, constructing or in retuning  
something. Fairly new to this all. So any thoughts, tips, alternatives and/or  
solutions very welcome!
