Comments (7)
Should we have developers explicitly call initialize? or just explicitly call the super class constructor from the constructor of the extending class?
i.e.
function MyDisplayObject()
{
DisplayObject.call(this);
}
MyDisplayObject.prototype = new DisplayObject();
Thoughts?
from easeljs.
That syntax is certainly neater than that used in the examples bundled with Easel at the moment. Are there any disadvantages over the current suggested?
Child.prototype = new Parent();
Child.prototype._super = Child.prototype.initialize;
Child.prototype.initialize = function() {
this._super(); // call parent constructor
}
from easeljs.
I think that for now, we should address this with documentation. We can re-evaluate this for v0.4. See the Game example (Ship.js and SpaceRock.js) for a functional example of extending existing display objects.
from easeljs.
The question is what do we document?
I think:
function MyDisplayObject()
{
DisplayObject.call(this);
}
MyDisplayObject.prototype = new DisplayObject();
Is clearer and easier to understand than:
Child.prototype = new Parent();
Child.prototype._super = Child.prototype.initialize;
Child.prototype.initialize = function() {
this._super(); // call parent constructor
}
It also requires less internal knowledge about how the base class is implemented.
However, perhaps there is a functional difference between the two that is not immediately obvious to me.
from easeljs.
The question is what do we document?
I think:
function MyDisplayObject()
{
DisplayObject.call(this);
}
MyDisplayObject.prototype = new DisplayObject();
is clearer and easier to understand than:
Child.prototype = new Parent();
Child.prototype._super = Child.prototype.initialize;
Child.prototype.initialize = function() {
this._super(); // call parent constructor
}
It also requires less internal knowledge about how the base class is implimented.
However, perhaps there is a functional difference between the two that is not immediately obvious to me.
from easeljs.
We are moving this to the 0.4.0 release, so we have some more time to discuss the issue (as well as what the recommended approach for inheritance is).
from easeljs.
I have added a tutorial that specifically addresses this. I'm also going to think further about the ParentClass.call() approach.
from easeljs.
Related Issues (20)
- sortChildren on Chrome not working - works in Firefox HOT 1
- Easel JS not working on codepen HOT 1
- Android text lineheight doesn't match Web or Windows HOT 2
- Memory leak when tween assigned HOT 1
- getBounds returns unexpected result after caching with a non-1 scale HOT 2
- can not cache with StageGL instance get "TypeError: Cannot create property 'width' on boolean" HOT 2
- Shadow "Stroke" appears on top of shape when using fill and strokestyle. HOT 4
- New touch issues on touch-screen boards with new Chrome HOT 4
- CreateJS touch 'pressmove' event
- Is it possible to make webgl mask work in animation? HOT 1
- Bitmap class - new createjs.Bitmap - SVG not loading at viewbox size HOT 1
- Text is still compressed when maxWidth is null HOT 1
- Mousemovement Performance improvement HOT 2
- Different Luminence values for Saturation vs Hue HOT 3
- Hit area detection on Samsung Internet Browser HOT 1
- When will you update createjs2.0? The current version of movieclip is incorrect, and stageGL cannot be used. HOT 4
- Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true HOT 6
- The Typescript Typings in DefinitelyTyped are missing Graphics.StrokeDash HOT 4
- Createjs website dose not work ! HOT 1
- StageGL antialias invalid. If scale!= 1 or rotation!=0.This bug will appear
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easeljs.