Skip to content

Instantiating Classes in AS3 Without eval() or []

Putting this here for safe keeping. Basically this is a way to deal with sound now in AS3. Previously it was documented how to do things with sound using attachSound, however that is no longer in AS3. Now, all the documentation points to loading in external MP3s and playing them that way. The problem I found, however, is that it’s not documented how to programatically manipulate audio in sounds which you create classes for in the library, (the new way of ‘linking’ things…)

Got RIA? » Instantiating Classes in AS3 Without eval() or [ ]

var dynamicClass:String = “com.brianmriley.apps.MyClass”;
var classRef:Class = flash.utils.getDefinitionByName(dynamicClass) as Class;
var myClass:com.brianmriley.apps.MyClass = new classRef();
// var myClass:* = new classRef();
//…much cleaner

FlashBrighton » Blog Archive » how to make actionscript 3 play generated pcm wave data

var soundClass:Class=loaderInstance.contentLoaderInfo.applicationDomain.getDefinition(“SoundClass”);
var sound:Sound=new soundClass();
sound.play();

Related posts:

  1. AS3 MAIN TIMELINE PRELOADER
  2. AS2/AS3 Speed Comparision Demo
  3. __Singularity__
  4. Connecting to AIM with ActionScript 3 Sockets
blog comments powered by Disqus