A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: How to make an MC know it's own name?

  1. #1
    Join Date
    Jan 2001

    How to make an MC know it's own name?

    For example, I have a MovieClip that has ten instances. I'd like each instance to be able to tell it's own name and load a different submovie, rather than handcoding each of the 10 MCs.

    So the mc with the instance "mc01" would be smart enough to load "subswf01.swf" and so on.

    Any ideas? Thanks in advance.

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Los Angeles
    There are a couple ways to do this.

    The movie's name is stored in the property


    and you can use string manipulation to extract out the numeric portion.

    Alternately, you can use the (more efficient) method I often use, which is that when you set up the movie, you assign a number to it, corresponding to the numeric portion of it's name.

    For example, if you're using a loop:


    for (var i = 1; i <= 10; ++i)
    var mc = _root.attachMovie("template", "mc"+i, i);
    mc.index = i; // this is the crucial part

    Then, the movie can always use this.index to retrieve that number and form other names with it.

  3. #3
    Join Date
    Jan 2001
    Exactly what I was looking for! Thanks so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center