diff --git a/src/extras/getChildByName.js b/src/extras/getChildByName.js new file mode 100644 index 0000000..29c651d --- /dev/null +++ b/src/extras/getChildByName.js @@ -0,0 +1,29 @@ +var DisplayObject = require('../core/display/DisplayObject'), + Container = require('../core/display/Container'); + +/** + * The instance name of the object. + * + * @member {string} + */ +DisplayObject.prototype.name = null; + +/** +* Returns the display object in the container +* +* @param name {string} instance name +* @return {DisplayObject} +*/ +Container.prototype.getChildByName = function (name) +{ + for (var i = 0; i < this.children.length; i++) + { + if (this.children[i].name === name) + { + return this.children[i]; + } + } + return null; +}; + +module.exports = {}; \ No newline at end of file diff --git a/src/extras/getChildByName.js b/src/extras/getChildByName.js new file mode 100644 index 0000000..29c651d --- /dev/null +++ b/src/extras/getChildByName.js @@ -0,0 +1,29 @@ +var DisplayObject = require('../core/display/DisplayObject'), + Container = require('../core/display/Container'); + +/** + * The instance name of the object. + * + * @member {string} + */ +DisplayObject.prototype.name = null; + +/** +* Returns the display object in the container +* +* @param name {string} instance name +* @return {DisplayObject} +*/ +Container.prototype.getChildByName = function (name) +{ + for (var i = 0; i < this.children.length; i++) + { + if (this.children[i].name === name) + { + return this.children[i]; + } + } + return null; +}; + +module.exports = {}; \ No newline at end of file diff --git a/src/extras/index.js b/src/extras/index.js index 61c24b5..267e97c 100644 --- a/src/extras/index.js +++ b/src/extras/index.js @@ -12,5 +12,6 @@ MovieClip: require('./MovieClip'), TilingSprite: require('./TilingSprite'), mesh: require('./mesh/index'), - cacheAsBitmap: require('./cacheAsBitmap') + cacheAsBitmap: require('./cacheAsBitmap'), + getChildByName: require('./getChildByName') };