# Function on dynamicaly created movie clips

**URL:** https://forum.kirupa.com/t/function-on-dynamicaly-created-movie-clips/189812
**Category:** flash
**Created:** [June 6, 2006, 11:58am UTC](https://forum.kirupa.com/t/function-on-dynamicaly-created-movie-clips/189812 "2006-06-06T11:58:49Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rajeshambady](https://avatars.discourse-cdn.com/v4/letter/r/f07891/32.png) [@rajeshambady](https://forum.kirupa.com/u/rajeshambady)
#### Post date: [June 6, 2006, 11:58am UTC](https://forum.kirupa.com/t/function-on-dynamicaly-created-movie-clips/189812/1 "2006-06-06T11:58:49Z")

</div>

importSubtemplate = new XML();  
importSubtemplate.ignoreWhite = true;  
importSubtemplate.onLoad = function(success) {  
if (success) {  
var depth = 0;  
var nextY = 10;  
count = 0;

var res = loadSubTemplate();  
var res:String = “” + res + “”;  
var tempimage:Array = res.split(",");

for (var j = 0; j\<tempimage.length; j++) {  
title = importSubtemplate.firstChild.childNodes[j].attributes.title;  
thumbnail = importSubtemplate.firstChild.childNodes[j].attributes.thumbnail;  
posx = importSubtemplate.firstChild.childNodes[j].attributes.xcoord;  
posy = importSubtemplate.firstChild.childNodes[j].attributes.ycoord;

var moviename = “moviename” + j;  
var movielevel = 1+j;

[COLOR=red]\_root.createEmptyMovieClip(“movie\_mc”, 25);  
movie\_mc.createEmptyMovieClip([moviename], movielevel);  
loadMovie(“images/” + thumbnail + “.jpg”, movie\_mc[moviename]);  
setProperty(movie\_mc[moviename], \_x, posx);  
setProperty(movie\_mc[moviename], \_y, posy); [/COLOR]  
}

[COLOR=darkred]movie\_mc.onRelease = function() {  
trace(movie\_mc[moviename]);  
};[/COLOR]

}  
}

importSubtemplate.load(“SubTemplatesConfig.xml”);

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
//Function

function loadSubTemplate(){  
var tempnew = importSubtemplate.firstChild;  
var temp:Array = new Array();  
for(i = 0; i\<tempnew.childNodes.length; i++){  
temp.push(tempnew.childNodes\*.attributes.title);  
}  
return (temp);  
}

Hi,  
In this code the images are loading from the server thrugh the XML file into the movie clips  
movie\_mc.moviename0, movie\_mc.moviename1, movie\_mc.moviename2, etc.  
I want to click on each item and at that time some action I have to write. Now I want like when I click on the first image a message with name of the first image comes like that.

but in my code  
[COLOR=darkred]movie\_mc.onRelease = function() {  
trace(movie\_mc[moviename]);  
};[/COLOR]

–when click on any image the same message comes… please help.
