# Outputting the mc name

**URL:** <https://forum.kirupa.com/t/outputting-the-mc-name/29312>\
**Category:** Uncategorized\
**Created:** [August 25, 2003, 4:24pm UTC](https://forum.kirupa.com/t/outputting-the-mc-name/29312 "2003-08-25T16:24:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![j0se](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/j0se/32/44_2.png) [@j0se](https://forum.kirupa.com/u/j0se)\
**Post date:** [August 25, 2003, 4:24pm UTC](https://forum.kirupa.com/t/outputting-the-mc-name/29312/1 "2003-08-25T16:24:55Z")

</div>

hello

i have a child mc with a loadVars event that gets some text from a file and loads it into a text box.

the parent mc is called about\_us

what i want to do is tell loadVars to look for a file of the same name as the parent clip (instead of hard-coding the name - so i can reuse it in other clips in the same project)

this is what i have at the moment:

.  
.  
.  
// load data  
myData.load(“myFile.txt”);  
.  
.

whereas i want something like:  
mydata.load(parent.name + “.txt”);

all the mc’s ahve an instance name, and i can do:  
trace(this);  
which gives me \_root.parentclipname.loadVars\_mc

but i want to output the parent clip name  
trace(parent) and other combinations don’t work

can anybody help?🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 25, 2003, 4:39pm UTC](https://forum.kirupa.com/t/outputting-the-mc-name/29312/2 "2003-08-25T16:39:57Z")

</div>

[AS]myData(\_parent.\_name+".txt");[/AS]  
?? 😛

[http://www.macromedia.com/support/flash/action\_scripts/actionscript\_dictionary/actionscript\_dictionary541.html](http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary541.html)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 25, 2003, 4:45pm UTC](https://forum.kirupa.com/t/outputting-the-mc-name/29312/3 "2003-08-25T16:45:02Z")

</div>

you saved the day again!!! :rambo:

thanks very much!

PS bloody syntax problems… i remember when it was all simple… :bad:

actually - what i now need to do is this:

//get parent name  
parent\_mc = \_parent.\_name

// strip the “\_mc” bit off the end  
…  
// then add the “.txt” extension

i’ll try and work this one out, but i will check here in an hour if i haven’t managed it (just to peek, in case the nice man with the god’s code book has told me how - again -

cheers!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 25, 2003, 4:48pm UTC](https://forum.kirupa.com/t/outputting-the-mc-name/29312/4 "2003-08-25T16:48:17Z")

</div>

😛

You’re welcome, j0se. 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 25, 2003, 5:05pm UTC](https://forum.kirupa.com/t/outputting-the-mc-name/29312/5 "2003-08-25T17:05:38Z")

</div>

i managed to do the last bit of what i wanted! i’m just wondering if this is the right way to do it:

// get the name of the parent mc  
mc\_name = \_parent.\_name;

// strip the “\_mc” bit off the end  
// get the string length  
stringLength = mc\_name.length;

```
//strip last 3 characters
mc_name = mc_name.substring(0,(stringLength-3));

```

// add the “.txt” extension  
mc\_name = mc\_name + “.txt”;

the obvious problem with this is that in order to reuse this code the names of the movie-clips must always have the “\_mc” extension. i can’t think of why i might need to omit this in an mc’s name, but it still strikes me as a flaw

would you do it differently?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 25, 2003, 5:12pm UTC](https://forum.kirupa.com/t/outputting-the-mc-name/29312/6 "2003-08-25T17:12:30Z")

</div>

If you always add the underscore before the suffix, you could use something like this:  
[AS]// get the name of the parent mc  
mc\_name = \_parent.\_name;  
// strip the “_suffix" bit off the end  
mc\_name = mc\_name.split("_”)[0];  
// add the “.txt” extension  
mc\_name = mc\_name+".txt";[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 25, 2003, 5:14pm UTC](https://forum.kirupa.com/t/outputting-the-mc-name/29312/7 "2003-08-25T17:14:55Z")

</div>

that’s much neater

ta!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 25, 2003, 5:16pm UTC](https://forum.kirupa.com/t/outputting-the-mc-name/29312/8 "2003-08-25T17:16:00Z")

</div>

You’re welcome… again. 😛
