Source: extras/getChildByName.js

extras/getChildByName.js

  1. import * as core from '../core';
  2. /**
  3. * The instance name of the object.
  4. *
  5. * @memberof PIXI.DisplayObject#
  6. * @member {string} name
  7. */
  8. core.DisplayObject.prototype.name = null;
  9. /**
  10. * Returns the display object in the container
  11. *
  12. * @method getChildByName
  13. * @memberof PIXI.Container#
  14. * @param {string} name - instance name
  15. * @return {PIXI.DisplayObject} The child with the specified name.
  16. */
  17. core.Container.prototype.getChildByName = function getChildByName(name)
  18. {
  19. for (let i = 0; i < this.children.length; i++)
  20. {
  21. if (this.children[i].name === name)
  22. {
  23. return this.children[i];
  24. }
  25. }
  26. return null;
  27. };