Event-Handler on a loaded Picture

Hey Guys,

I think I’m getting crazy :crazy:
I don’t get my stupid script to work.

Alright, I try to create an emptyMC (this works ;-))
Then I laod an image to that MC with load movie.
Now I want to give the MC an Event-Handler.

Here ist what I tried so far:

[AS]
for (xy=1; xy<5; xy++) {
createEmptyMovieClip(“dodo”+xy, xy);
_root[“dodo”+xy].loadMovie(“w.swf”, xy);
_root[“dodo”+xy]._x += sx;
_root[“dodo”+xy]._y += sy;
sx += 75;
sy += 75;
}
[/AS]

Ok this creats now 5 MC’s and move them 75 on the x and y.

This works fine but the eventhandler is empty wenn I use this:

I have an empty MC wich has this action

[AS]

onClipEvent (enterFrame) {
for (xa=1; xa<5; xa++) {
_root[“dodo”+xa].onRollOver = function() {
_root[“dodo”+xa]._x += 10;
_root[“dodo”+xa]._y += 25;
};
}
}

[/AS]

It looks like that each Object has an event, because when I move the mouse over the even the courser changes, but nothing happens.

Has someone any sugguestions what I could try.
Or maybe there is an easier way to generate something like that.

Thanks vor you help

The events are deleted when you load the images. You have to wait for the images to be fully loaded before you can declare the handlers.

pom :slight_smile:

I figuered that, and thats the reason why I put the Even-Handler stuff in the
[AS]onClipEvent (enterFrame) {[/AS]

But this ist not working.

Where else could I put it?
Any hints ?

[AS]for (var p=1; p < 5; p++) {
// create the clip where you load the picture
var mc=this.createEmptyMovieClip(“dodo”+p, p);
mc.loadMovie(“w.swf”, p);
// create the clip that will preload the picture
this.createEmptyMovieClip(“controller”+p,p+500).onEnterFrame=function(){
// actual preload
var clip=eval(“dodo”+p);
var l=clip.getBytesLoaded();
var t=clip.getBytesTotal();
// when the clip is loaded
if (l && l >= t) {
// declare the rollover
clip.onRollOver = function() {
this._x += 10;
this._y += 25;
};
// delete the preloader clip
delete this;
}
}
}[/AS]Something like this. Reassigning the onRollOver handler onEnterFrame like you did was, in my opinion, a bad idea.

pom :phil:

I am a realy newbe in Flash so it was probably an bad Idea.
I tried everything just to get it work.

So thanx a lot for your help.
Now I will try to use it :wink:

I’m sorry, I made some typos in my code. They should be corrected.