Skip navigation
Currently Being Moderated

Toolkit for CreateJS after export instance names are not available in .name property of objects

Mar 22, 2013 2:27 PM

Tags: #flash #cs6 #name #instance_name #createjs

Inside a loop I connect a single click eventlistener to multiple objects. Inside the event listener I need to know what Button or MovieClip is clicked on.

In AS3 I used and it looks like createjs supports this because the property .name exists for all objects.


But the problem is that the name property is null in every object. I tried adding .name inside the exported js and that works, but to edit that file is not really an option.


I use this code for example :


for (i = 1; i <= 150; i++){

    myMC["childMC" + i].addEventListener("click",onChildClick);



function onChildClick(event){
   alert('clicked target' +;



Is this a bug or something or better yet, is there a workaround?

  • Currently Being Moderated
    Mar 26, 2013 12:59 PM   in reply to ferryfast

    Is there any reason you can't use child-iteration?


    for (i = 1; i <= container.getNumChildren(); i++){



    Mark as:
  • Currently Being Moderated
    Mar 30, 2013 4:49 PM   in reply to ferryfast

    Even though there is no name property, you could also probably use the existence of the property on the parent (similar to the name approach) since Toolkit injects the children using their instance name as the property name:



    var num = 0;

    for (i = 1; i <= container.getNumChildren(); i++){

        var name = "myMC" + i;

        if (container[name] != null) {

           // This is a "myMC#" child






    This would be easier if you knew the number of myMC children, since you could just use that as a loop instead of checking all the children.

    Mark as:
  • Currently Being Moderated
    Aug 22, 2013 6:16 AM   in reply to ferryfast

       Here's how i do it:

                var someContainer=new lib.SomeContainer();
                for(var childName in someContainer){      
                    if(someContainer[childName] instanceof createjs.DisplayObject) {
                        console.log(childName+" now has a name!!");
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points