# Why the following code isn't responding to the rollover event!

**URL:** <https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368>\
**Category:** Uncategorized\
**Created:** [April 27, 2003, 9:05am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368 "2003-04-27T09:05:02Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![adham\_a](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@adham\_a](https://forum.kirupa.com/u/adham_a)\
**Post date:** [April 27, 2003, 9:05am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/1 "2003-04-27T09:05:02Z")

</div>

Hello all,  
it’s me again the problem is that i created two empty movie clips on \_level0, loaded a picture in them, scaled, positioned and rotated them. and then i need to swap their depths on rollover but their is no response even the trace isn’t working. can anybody help.

thanks

[AS]  
\_level0.createEmptyMovieClip(“f1”,1000);  
\_level0.f1.\_x = 580;  
\_level0.f1.\_y = 185;  
\_level0.createEmptyMovieClip(“f2”,1001);  
\_level0.f2.\_x = 580;  
\_level0.f2.\_y = 185;  
\_level0.f1.loadMovie("…/Photos/GDSPhotos/" + tempID + “.jpg”);  
\_level0.f1.\_xscale = \_level0.f1.\_xscale \* 0.63666667;  
\_level0.f1.\_yscale = \_level0.f1.\_yscale \* 0.6875;  
\_level0.f1.\_rotation = 3.1;  
\_level0.f2.loadMovie("…/Photos/GDSPhotos/" + tempID + “.jpg”);  
\_level0.f2.\_xscale = \_level0.f2.\_xscale \* 0.63666667;  
\_level0.f2.\_yscale = \_level0.f2.\_yscale \* 0.6875;  
\_level0.f2.\_rotation = -3.1;  
\_level0.f1.onRollOver = function () {  
\_level0.f1.swapDepths(“f2”);  
trace(“Rollf1”);  
}  
\_level0.f2.onRollOver = function () {  
\_level0.f2.swapDepths(“f1”);  
trace(“Rollf2”);  
}  
[/AS]

---

<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:** [April 27, 2003, 12:10pm UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/2 "2003-04-27T12:10:48Z")

</div>

I don’t think you should be using a function in this case.

\_level0.f1.onRollOver {  
\_level0.f1.swapDepths(“f2”);  
trace(“Rollf1”);  
}  
\_level0.f2.onRollOver {  
\_level0.f2.swapDepths(“f1”);  
trace(“Rollf2”);  
}

---

<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:** [April 27, 2003, 4:50pm UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/3 "2003-04-27T16:50:18Z")

</div>

- adham\_a

the problem, when you load a swf/jpg into a MovieClip everything in that MovieClip is erased and replaced with the new content, including event handlers.

you could preload the swf/jpg and then assign the event handler(s).  
or [http://www.kirupaforum.com/forums/showthread.php?s=&threadid=21630](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=21630)

- Fluffy Bunny

you have to declare dynamic event handlers as functions.

---

<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:** [April 27, 2003, 9:17pm UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/4 "2003-04-27T21:17:49Z")

</div>

thanks for the reply it was very helpfull.  
i created another movieclip within the first one to hold the figure and attached the actions to the parent movieclip.

I have now another problem (little one) as you can see if you loaded a picture into f1 and f2 they overlap each other almost completely only a little portio of the edge is still shown. I want to swap depth when the user rollover these edges this works fine but the problem is when i pass the mouse over the part of the image where the two images overlap it begin to change between the two photos at high speed.

how can i define that the only place where iwant swapdepth to eork is on the edges.

thanks

---

<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:** [April 28, 2003, 1:57am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/5 "2003-04-28T01:57:38Z")

</div>

sorry… i was a bit busy. :-\

anyway, could you attach your fla? i’m not sure that i understood the problem. 😛

---

<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:** [April 28, 2003, 3:58am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/6 "2003-04-28T03:58:31Z")

</div>

sorry kax didn’t notice your reply earlier

this is the file i had

couldn’t post the fla (too big)

i used the same code posted previously with an embedded clip in the f1 and f2 clips to hold the pictures

---

<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:** [April 28, 2003, 4:12am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/7 "2003-04-28T04:12:14Z")

</div>

well… there are no images in the zip and i don’t know the value of the variable tempID so that’s useless to me. :-\

send me the fla to: \*\*\*\*\*@msn.com 😉

---

<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:** [April 28, 2003, 4:21am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/8 "2003-04-28T04:21:47Z")

</div>

ok sending the file

it seems i am taking a lot from your time thanks a lot

---

<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:** [April 28, 2003, 4:27am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/9 "2003-04-28T04:27:38Z")

</div>

it’s ok. i like to help people. 😉 =)

---

<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:** [April 28, 2003, 4:29am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/10 "2003-04-28T04:29:22Z")

</div>

hello kax

i got a delivery notice error when i sent you the file it seems that your inbox is full or something like that the attachment size is 389kb

your mail is right

---

<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:** [April 28, 2003, 4:40am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/11 "2003-04-28T04:40:41Z")

</div>

hello kax this is an swf file that loads two jpegs called 1 and 2 from the folder called Photos place the swf in a folder named Whatever and place the Photos folder and the Whatever folder in another folder

i don’t know why flash have this path naming thing

thanks again

---

<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:** [April 28, 2003, 4:48am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/12 "2003-04-28T04:48:19Z")

</div>

check your PM’s. 🙂

---

<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:** [April 28, 2003, 5:38am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/13 "2003-04-28T05:38:05Z")

</div>

fixed. =)

```auto
f1.onRollOver = function() {
	if (this.getDepth()<f2.getDepth()) this.swapDepths(f2);
};
f2.onRollOver = function() {
	if (this.getDepth()<f1.getDepth()) this.swapDepths(f1);
};

```

---

<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:** [April 28, 2003, 5:48am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/14 "2003-04-28T05:48:40Z")

</div>

😛😛😛😛😛

man you are reaaaaaaaaaaaaaaaaally the one (you can even take it like the ONE in the MATRIX)

1- thanks a lot for your help really really really really really

2- do you how long i’ve been searching for the function that returns the depth of an object i thought first that it is like a property as \_x or \_y and never thought it had an independent function really thanks

and hope that you can help me again 😉

---

<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:** [April 28, 2003, 5:56am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/15 "2003-04-28T05:56:49Z")

</div>

😛

1. i said it before and i’ll say it again… i like to help people. =)

2. you should check the actionscript dictionary every now and then. 😉

---

<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:** [April 28, 2003, 6:03am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/16 "2003-04-28T06:03:28Z")

</div>

ok i’ll take your last reply as a YES for my message’s question.

these are the questions:

- why my fla file the one i sent for you was so large although it contained nothing in its library. (only code as you saw)

- do you know how i can load formatted text into a text field in flash (other than using HTML formatting)

- this is out of scope: is their a way to pass a value from director to flash if the flash swf is contained in the director project

thanks again

---

<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:** [April 28, 2003, 6:16am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/17 "2003-04-28T06:16:12Z")

</div>

1. i don’t know the reason… :crazy:  
but try this: open your fla, go to File | Save As… and save a new fla, usually the file size is decreased when i do that. =)

2. i don’t think you can… :-\

3. no idea, i’ve never used director. sorry. ☹

and thanks for your understanding in the PM. =)

---

<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:** [April 28, 2003, 6:20am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/18 "2003-04-28T06:20:33Z")

</div>

thanks for your help today it was very valuable

hope to hear from you and maybe even help you in return in the future

:cyborg:

---

<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:** [April 28, 2003, 6:28am UTC](https://forum.kirupa.com/t/why-the-following-code-isnt-responding-to-the-rollover-event/19368/19 "2003-04-28T06:28:17Z")

</div>

😉

no problem… glad i could help. =)
