Posted By

adrianparr on 01/20/11


Tagged

class object String name convert cast as3 instantiate getDefinitionByName


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

kure69


AS3 Convert An Object To A Class By Name


 / Published in: ActionScript 3
 

URL: http://evolve.reintroducing.com/2009/08/03/tips-n-tricks/tip-convert-an-object-to-a-class-by-name/

Here is an example of a sound that is in a library with the class field set to MySound.

  1. import flash.utils.getDefinitionByName;
  2.  
  3. var SoundRef:Class = getDefinitionByName("MySound") as Class;
  4. var _sound:Sound = new SoundRef();
  5. _sound.play();

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: adrianparr on July 24, 2012

This is quite helpful too ... http://baldscone.com/?p=169

You need to login to post a comment.