1

Hi Guys (sorry for my bad english),

I've stuck with this in a week, is it possible to get the movieclip instance name with createJS (I've put the movieclip manually on the stage and I give it an instance name), in AS3 I can use movieclip.name to get the instance name, how can I do that in createJS, when I use this.movieclipName.name it always return null in console log, do You have any suggestion? Thanks for Your help?

Arfian90
  • 71
  • 1
  • 12
  • Just curious: why do you need the "name"? The instance name you use in Flash becomes the reference name in the parent element (exportRoot.myInstanceName). – Lanny Feb 25 '15 at 16:21
  • Thanks for asking Lanny, I want to doing a loop to scan/read all the movieclip from parent with special name like `object1`, `object2`, etc. I'm thinking to doing something like this: `for (var k in this){ /*get all movieclip instances name */ if(this[k].name.substring(0,7)=='object'){ //do something, like put it in array }}` but it didn't work, when I'm trying to see the name of the movieclip it always return null in the console log. – Arfian90 Feb 26 '15 at 03:45
  • When doing a loop you can reference it like (where i is the index): var myobject = stage["object"+i]. – Ferry Kranenburg Feb 28 '15 at 07:46

2 Answers2

0

@Ferry thank You very much for Your solution. finally I figured it out, We can't get the instance name of the object by myObject.name because the name of the object is not signed previously (it looks like the instance name not same as name in html5). that's why it always giving a null. This is my script to get all the instances name of my objects.

for (var a = 0; a <= maxObject - 1; a++) {
   var myObjectName = 'object' + (a + 1);
   var myObject = this[arrObject[a]];

   myObject.name = myObjectName;
}

Thank you guys for all of your respon.

Arfian90
  • 71
  • 1
  • 12
0

i solve this problem using:

for (i = 1; i < 6; i++) {
this["m" + i].addEventListener("click", clickme.bind(this));
this["m" + i].hamdy=i;}

so you can use var hamdy to pass any change in clickme funaction.