# Event-Handler on a loaded Picture

**URL:** <https://forum.kirupa.com/t/event-handler-on-a-loaded-picture/16789>\
**Category:** flash\
**Created:** [March 28, 2003, 8:49am UTC](https://forum.kirupa.com/t/event-handler-on-a-loaded-picture/16789 "2003-03-28T08:49:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mungo\_ac](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@mungo\_ac](https://forum.kirupa.com/u/mungo_ac)\
**Post date:** [March 28, 2003, 8:49am UTC](https://forum.kirupa.com/t/event-handler-on-a-loaded-picture/16789/1 "2003-03-28T08:49:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 28, 2003, 11:34am UTC](https://forum.kirupa.com/t/event-handler-on-a-loaded-picture/16789/2 "2003-03-28T11:34:45Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 28, 2003, 12:46pm UTC](https://forum.kirupa.com/t/event-handler-on-a-loaded-picture/16789/3 "2003-03-28T12:46:08Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 28, 2003, 12:54pm UTC](https://forum.kirupa.com/t/event-handler-on-a-loaded-picture/16789/4 "2003-03-28T12:54:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 28, 2003, 1:00pm UTC](https://forum.kirupa.com/t/event-handler-on-a-loaded-picture/16789/5 "2003-03-28T13:00:00Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 28, 2003, 1:11pm UTC](https://forum.kirupa.com/t/event-handler-on-a-loaded-picture/16789/6 "2003-03-28T13:11:38Z")

</div>

I’m sorry, I made some typos in my code. They _should be_ corrected.
