# Instantation attempted on a non-constructor OR Argument name must not be null

**URL:** <https://forum.kirupa.com/t/instantation-attempted-on-a-non-constructor-or-argument-name-must-not-be-null/310653>\
**Category:** Uncategorized\
**Created:** [June 15, 2010, 9:25pm UTC](https://forum.kirupa.com/t/instantation-attempted-on-a-non-constructor-or-argument-name-must-not-be-null/310653 "2010-06-15T21:25:10Z")\
**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 15, 2010, 9:25pm UTC](https://forum.kirupa.com/t/instantation-attempted-on-a-non-constructor-or-argument-name-must-not-be-null/310653/1 "2010-06-15T21:25:10Z")

</div>

I’m trying to create a virtual piano and I am having difficulty.  
If I write the code as follows:

```php
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 {
	this[keys* + "sound"]= getDefinitionByName (this[keys*]) as Class;
	keys* = new this[keys* + "sound"]();
	
	}
	;
	this["key_" + keys*].addEventListener(MouseEvent.ROLL_OVER, (this["play" + keys* + "sound"]));
	this["key_" + keys*].addEventListener(MouseEvent.CLICK, (this["play" + keys* + "sound"]));

}

```

where all of the sounds are linked to the names in the keys array, I receive the following error after clicking the keys:

> ArgumentError: Error #1507: Argument name cannot be null.  
> at global/flash.utils::getDefinitionByName()  
> at MethodInfo-40()

If I change the first two lines in the function declaration to

```php
this[keys* + "sound"]= new [keys*]();
	this[keys* + "sound"].play(550);

```

I get the following error after clicking the keys:

> TypeError: Error #1007: Instantiation attempted on a non-constructor.  
> at MethodInfo-40()

I need to create this for a final project in an online course - the project is due next Friday and this is only part of it.

Any help is HIGHLY appreciated.
