# Dynamically accessing static variable between two classes: cutom key pressing

**URL:** <https://forum.kirupa.com/t/dynamically-accessing-static-variable-between-two-classes-cutom-key-pressing/285908>\
**Category:** flash\
**Created:** [April 7, 2009, 6:23pm UTC](https://forum.kirupa.com/t/dynamically-accessing-static-variable-between-two-classes-cutom-key-pressing/285908 "2009-04-07T18:23:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaedo](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@Shaedo](https://forum.kirupa.com/u/Shaedo)\
**Post date:** [April 7, 2009, 6:23pm UTC](https://forum.kirupa.com/t/dynamically-accessing-static-variable-between-two-classes-cutom-key-pressing/285908/1 "2009-04-07T18:23:17Z")

</div>

End point I am trying to allow users to define their own key preferences.  
My approach currently is as follows:

I have a .as called ‘Keys’. It has some boolean variables corresponding to a set of keys and allows global access to the key press status.  
eg

```auto
 
package
{
     public class Keys
{
      public static var a:Boolean = false;
     //etc
}
}

```

I also have a .as called ‘KeyWatcher’.  
It handles all the listeners for key presses etc.  
It has a peice of code that does not work:

```auto
 
 protected function keyPressHandler(event:KeyboardEvent):void
 {
  var Keys_a:String = 'Keys.a';

  switch(event.charCode)
  {
   case 97:
   Boolean(Keys_a) = true; // error 1105: Target of assignment must be a reference value.
   break;   
  }

```

I know why I am getting the 1105 error, I just put this in as an example to try and convey what I was trying to do.

I want to keep the reference as a variable (eg Keys\_a) so I can reasign its target (eg Keys\_a = ‘Keys.b’)

[COLOR=black][FONT=Verdana]I apologise for the convoluted status of my query but I am not really sure what approach I should be taking. [/FONT][/COLOR]

thanks for taking the time to consider my question.
