Can someone help me clean this up a bit?
private function playRandomAppleSound():void {
var snd:Sound;
var rnd:uint = Math.ceil(Math.random() * 7);
switch(rnd){
case 1:
snd = new Banjo_1();
break;
case 2:
snd = new Banjo_2();
break;
case 3:
snd = new Banjo_3();
break;
case 4:
snd = new Banjo_4();
break;
case 5:
snd = new Banjo_5();
break;
case 6:
snd = new Banjo_6();
break;
case 7:
snd = new Banjo_7();
break;
}
var chnl:SoundChannel;
chnl = snd.play();
}
Those Banjo1, Banjo_2 classes are for library sound clips of notes played on a banjo. In AS2 I could've done this neater by dynamically creating the linkage ID I wanted, e.g. "Banjo" + rnd.
Is there a way to do similar in AS3?
Not tried it but a really bad one liner may work?
(new ( getDefinitionByName( 'Banjo_'+String(Math.ceil(Math.random() * 7)) ) as Class )).play();
awesome thanks JLM:
private function playRandomAppleSound():void {
var snd:Sound;
var rnd:uint = Math.ceil(Math.random() * 7);
var RandomBanjoClass:Class = getDefinitionByName("Banjo_" + rnd) as Class;
snd = new RandomBanjoClass();
var chnl:SoundChannel;
chnl = snd.play();
}
works a charm 
Originally posted by: JLM
(new ( getDefinitionByName( 'Banjo_'+String(Math.ceil(Math.random() * 7)) ) as Class )).play();
lol.. I have a frustrating client at the moment and I think I might do that to every line of AS before hand over the source 
there is now a haxebundle for a haxe and it compiles from textmate I managed to get the hello worlds to work last night, why not port it (there is a as3 generator if they then hassle you). I am sure that will fox them ps I think there maybe an error in the line above.