Useing an event on an dynamic generated Object

Hi,
I am trying to put an actionscript on an dynamic gernerated Object. But I can’t find how to do it.
The lasting thing I tried was something like that:

counter =1;
while (counter < 10) {
_root.box.duplicateMovieClip(“obj”+counter, counter);
_root[“obj”+counter].onRollOver = function() {
debug.text = “It’s working!”;
}
counter +=1
}

but its not working @all.

Any Idea how I have to do it?

theres nothing wrong with that code. You might have to check to see if debug is right. It should be a textfield in the timeline of that script with the instance name debug

maybe it’s just that each duplicated movie clip is at the same x and y coordinates than the original. that’s why you don’t see them.

try this:

counter = 1;
while (counter<10) {
	_root.box.duplicateMovieClip("obj"+counter, counter);
	_root["obj"+counter]._x = box._width*counter;
	_root["obj"+counter].onRollOver = function() {
		debug.text = "It's working!";
	}
	counter++;
}

and you can use for too…

for (counter=1; counter<10; counter++) {
	_root.box.duplicateMovieClip("obj"+counter, counter);
	_root["obj"+counter]._x = box._width*counter;
	_root["obj"+counter].onRollOver = function() {
		debug.text = "It's working!";
	}
}

I know it should work, but its not.
I have no idea why

Here ist my test fla, maybe someone can find the Problem

Ohh i am sorry it works.
I forgot the rolover line in the fla.

Now I will try tu put it in my main fla.
thanx a lot

:beam:

no problem :wink: =)

Ok finaly I found why its not working.
I have a MC with an image.
Now I want to duplicate that MC and also changing the image.
I tried to use an loadmovie to load an MC with just that image.
This works realy fine. But afert that the event is not working anymore.

Here is the code I used

[AS]
on (release) {
for (counter=1; counter<10; counter++) {
_root.box.duplicateMovieClip(“obj”+counter, counter);
_root[“obj”+counter].loadMovie(“w.swf”);
_root[“obj”+counter]._x = random(550);
_root[“obj”+counter]._y = random(150);
_root[“obj”+counter].onRollOver = function() {
_root.debug.text = “It’s working!”;
};
}
}

[/AS]

I guess I have to set the target

[AS]
loadMovie(“w.swf”, target/level)
[/AS]

but I have no glue what it is?
Is it the counter?

here’s why it doesn’t work… =)
http://www.kirupaforum.com/forums/showthread.php?s=&threadid=16214

I tried now a little bit arround, but I don’t get it.
What exactly do I have to do, to get it work?
Do I have to do an loadMovie first und later I have to call an function what creates or duplicate that MC and gives it the event-action ?

I tried that at last:

[AS]

on (rollOver) {
_root.box.loadMovie(“k.jpg”,0);
}
on (release) {
for (counter=1; counter<10; counter++) {
_root.box.duplicateMovieClip(“obj”+counter, counter);
_root[“obj”+counter]._x = random(550);
_root[“obj”+counter]._y = random(150);
_root[“obj”+counter].onRollOver = function() {
_root.debug.text = “It’s working!”;
};
}
}

[/AS]

But as soon as I release, nothing happens.
As soon I comment the loadMovie out, I can see that it is working (debugger) but without the image.

Any hints ?