Detecting dynamically movieclip name

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.


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);
}


<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:

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:

mcMain.mainMenu.nomeMovieClip.addChild(loader);

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