To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 06-09-2004, 08:49 PM   #1
Danger Madcow
Member
 
Join Date: Jan 2001
Posts: 51
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.
Danger Madcow is offline   Reply With Quote
Old 06-09-2004, 09:02 PM   #2
jbum
Senior Member
 
jbum's Avatar
 
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
There are a couple ways to do this.

The movie's name is stored in the property

movie._name;

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:

code:

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.
__________________
jbum is offline   Reply With Quote
Old 06-09-2004, 10:09 PM   #3
Danger Madcow
Member
 
Join Date: Jan 2001
Posts: 51
Exactly what I was looking for! Thanks so much!
Danger Madcow is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:15 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.