# Detecting dynamically movieclip name

**URL:** <https://forum.kirupa.com/t/detecting-dynamically-movieclip-name/309072>\
**Category:** flash\
**Created:** [May 6, 2010, 9:47am UTC](https://forum.kirupa.com/t/detecting-dynamically-movieclip-name/309072 "2010-05-06T09:47:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LS05](https://avatars.discourse-cdn.com/v4/letter/l/e19b73/32.png) [@LS05](https://forum.kirupa.com/u/LS05)\
**Post date:** [May 6, 2010, 9:47am UTC](https://forum.kirupa.com/t/detecting-dynamically-movieclip-name/309072/1 "2010-05-06T09:47:10Z")

</div>

Hi guys,  
I’m trying to load different images from xml to movieclips by detecting the movieclips name dynamically via xml.  
Pratically i have 2 movieclips named “sera” and “diurno”.  
I take the names and the relative urls via xml then i try to add the images to the moviclip that have the same name as the xml, so i know that the “sera” movieclip have the “sera” image.

```auto

var loader:Loader;
var nomeMovieClip:String;
for(var i:uint = 0; i < menuImgs.length(); i++)
{
        nomeMovieClip = menuImgs*.@nome;
    loader = new Loader();
    loader.load(new URLRequest(menuImgs*.@url));
    mcMain.mainMenu.nomeMovieClip.addChild(loader);
}

```

```auto

<sfondi>
    <home url="backgrounds/sfondohome.jpg" />
    <immaginemn url="immagini/sera.jpg" nome="sera" />
    <immaginemn url="immagini/sera.jpg" nome="diurno" />
</sfondi>

```

The problem is that when i compile this it gives me this error:

```auto
TypeError: Error #1010: Un termine risulta undefined e non ha proprietà.
    at main/menuImgInit()[D:\Lavori\villa cafiero\sito\main.as:98]
    at main/completeXML()[D:\Lavori\villa cafiero\sito\main.as:48]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

```

on this line:

```auto
mcMain.mainMenu.nomeMovieClip.addChild(loader);

```

Why? maybe because i refer to a movieclip with a string?  
Please help me 🙂
