I’m trying to create a virtual piano.
Code is as follows:
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.CLICK, (this[“play” + keys* + “sound”]));
}
The sounds are linked as c or csharp or d… and so on.
The lines in bold are wrong. I think I’m supposed to use getDefinitionByName but I don’t know how :S
Thanks for the help in advance.