AS3 | KCClassFactory


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. package kc.core {
  2.  
  3. public class KCClassFactory extends Object implements IPurger {
  4.  
  5. // @protected
  6.  
  7. protected var _value:Class;
  8. protected var _properties:Object;
  9.  
  10. // @constructor
  11.  
  12. public function KCClassFactory( value:Class ) {
  13. super();
  14. _value = value;
  15. }
  16.  
  17. // @getters
  18.  
  19. public function get properties():Object {
  20. return this._properties;
  21. }
  22.  
  23. // @methods
  24.  
  25. public function newInstance( properties:Object = null ):Class {
  26. var instance:Class = new _value();
  27. if( properties != null ){
  28. _properties = properties;
  29. for( var key:String in _properties ){
  30. instance[key] = _properties[key];
  31. }
  32. } return instance;
  33. }
  34.  
  35. // @purge
  36.  
  37. public function purge(...rest):void {
  38. _properties = null;
  39. _value = null;
  40. }
  41.  
  42. }
  43.  
  44. }

URL: http://www.kirikacode.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.