extend(subclass, superclass, override, prefix, prototype)
extend zim function - modified CreateJS extend and promote utility methods DESCRIPTION For ES5 - place after a sub class to extend a super class. Extending a super class means that the sub class receives all the properties and methods of the super class. For example, a ZIM Container() extends a CreateJS Container and then adds more methods and properties but all the CreateJS Container methods and properties are still there too like x, y, addChild(), etc. For ES6 - do not use zim.extend() but rather use the built in ES6 structures as follows: EXAMPLE
// ES6 - do NOT use zim.extend()
class Person() {
   constructor () {
      zog("I am a person");
   }
}
class Woman extends Person { // use JS6 extends keyword
   constructor () {
      super(); // use JS6 super() to call the Person constructor - will do the zog()
      // Woman code
   }
}

// ES6 to extend a zim Container for example (do NOT use zim.extend() in ES6)
class ChineseCoin extends Container { // use JS6 extends keyword
   constructor () {
      super(); // must call the zim Container before using keyword this
      new Circle(100, "gold").addTo(this); // this will be the zim Container
      new Rectangle(100, 100, "brown").center(this);
   }
}
var coin = new ChineseCoin().center(); // coin is a zim Container with Circle and Rectangle inside
NOTE as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim) EXAMPLE
// ES5 examples using functions to make classes
// ES5 has no extends keyword and no super keyword so we use zim.extends()
function Person() {
   this.talk = function() {
      zog("I am a person");
   }
}
function Woman() {
   this.super_constructor(); // part of the zim.extend() system
}
extend(Woman, Person); // here is the zim.extend() for ES5
var woman = new Woman();
woman.talk();
NOTE CreateJS display objects require their constructor to be called otherwise it is like quantum entanglement (seriously) extend() adds access to the super class constructor so it can be called in the subclass as follows: this.super_constructor(); It also provides access to super class methods that are overridden NOTE as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim) EXAMPLE
// ES5 example - see the ES6 set of examples for ES6 ;-)
// make a Collection class that will extend a Container
// the Collection class will call the Container constructor
// and override the the ZIM Container center method in the class body
// and override the CreateJS Container addChild method in the prototype
// either method would work in either place - it is often a matter of preference
// but you might need to use a method in the class body to access local variables
// The ZIM extend() method parameter values need to change depending on where you override
// see the comments inline for the instructions

var Collection = function() {
   // for CreateJS the super constructor must be run
   this.super_constructor();

   // override the zim center() method
   // methods in the function call that override must be passed in as an array of strings
   // to the override parameter of extend() to be able to access the super_method
   this.center = function(where) {
      this.super_center(where);
      this.y -= 50;
   }
}
// override the super class addChild() that comes from the CreateJS Container
// methods on the prototype that override are automatically provided a super_method
// unless the prototype parameter of extend() is set to false (default is true)
Collection.prototype.addChild = function(c) {
   this.super_addChild(c); // call the super class addChild
   zog("added a child to Collection");
}

// make the Collection extend a Container()
// it will receive all the properties and methods of the Container plus its own
extend(Collection, Container, CENTER); // or pass an array of overridden methods

// use the Collection
var c = new Collection();
c.addChild(new Rectangle(100, 100, green)); // zogs "added a child to Collection"
c.center(); // centers the collection but then offsets it 50 pixels up
NOTE the superclass constructor is always available as this.prefix_constructor() no matter the override or prototype settings NOTE this.prefix_constructor(); should be called at the top of the subclass to avoid problems when multiple copies of object NOTE to extend a class that already extends a ZIM class then change the prefix to a unique name: EXAMPLE
// if we already had the Collection example above and we want to extend that
// then we must use a new prefix when using extend()

var Records = function() {
   this.Collection_constructor();
}
extend(Records, Collection, null, "Collection");

// you will still have this.super_center(), this.super_addChild() if needed
// plus any newly overridden methods available as this.Collection_methodName() etc.
var r = new Records();
r.addChild(new Circle(20, pink));
r.super_center(); // call the original center (without vertical shift)

// to extend again, use yet another prefix - for example: "Records"
var Jazz = function() {
   this.Records_constructor();
}
extend(Jazz, Records, null, "Records");
PARAMETERS supports DUO - parameters or single object with properties below NOTE do NOT use zim.extend() with ES6 - see ES6 examples at top instead subclass - the class to extend superclass - the class to extend from (an existing class) override - (default null) an Array of methods (as Strings) to override.    You can override any function by just defining that function in the subclass    the override parameter gives you access to the overridden function in the superclass prototype    only methods on the superclass prototype can be accessed once overridden - not methods in the superclass body    if there is only one method being overridden then a single string is fine ("test" or ["test"] is fine)    any methods passed to this parameter will be given prefix_methodName() access on the sub class (this.prefix_methodName())    where the prefix is below (note, the prototype setting has no bearing on these manual overrides)    this list is only needed for methods in the subclass body    methods assigned to the prototype of the subclass that override are automatically given prefixes prefix - (default "super") a prefix that will be followed by "_" and then the overridden method name    by default this.super_constructor() would call the super class constructor    if prefix is set to "Person" then this.Person_constructor() would call the super class constructor    the same system is used to call overridden files in override or prototype prototype - (default true) will search the subclass prototype for overriding methods    the overridden methods are then available as this.prefix_methodName()    set to false to avoid searching the super class for methods overridden by the sub class prototype    just quickens the code minutely if there is no need NOTE extend() is included in Distill if DISPLAY, METHODS or FRAME Module classes are used (otherwise NOT included) RETURNS the subclass CODE ▤BITS VIDS