# CS3 Generating Variable Names

**URL:** https://forum.kirupa.com/t/cs3-generating-variable-names/310255
**Category:** flash
**Created:** [June 5, 2010, 11:22pm UTC](https://forum.kirupa.com/t/cs3-generating-variable-names/310255 "2010-06-05T23:22:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Michael\_Knight1](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@Michael\_Knight1](https://forum.kirupa.com/u/Michael_Knight1)
#### Post date: [June 5, 2010, 11:22pm UTC](https://forum.kirupa.com/t/cs3-generating-variable-names/310255/1 "2010-06-05T23:22:14Z")

</div>

So I’m trying to create a virtual piano using Adobe Flash CS3.  
I have a library graphic called “whitekey” and a library graphic called “key”.  
I also have library sounds corresponding the strings in the array.

The code in bold does not work as it gives me an “Expecting identifier before this” error. How would I fix this?

var keys: Array = [“c”,“csharp”,“d”,“dsharp”,“e”,“f”,“fsharp”,“g”,“gsharp”,“a”,“asharp”,“b”,“c2”];

for (var i:int = 0; i \< keys.length; i++) {

```
            this["play" + keys* + "sound"] = function (event:MouseEvent):void { 

```

\*\* var this[keys\* + “sound”]= new keys\*;  
this[keys\* + “sound”].play(550);}  
\*\*  
this[“key\_” + keys\*].addEventListener(MouseEvent.ROLL\_OVER, (this[“play” + keys\* + “sound”]));  
this[“key\_” + keys\*].addEventListener(MouseEvent.CLICK, (this[“play” + keys\* + “sound”]));
