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

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]

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”);
}

  • 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

  • Fluffy Bunny

you have to declare dynamic event handlers as functions.

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

sorry… i was a bit busy. :-\

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

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

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

ok sending the file

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

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

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

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

check your PM’s. :slight_smile:

fixed. =)

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

:stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue:

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

:stuck_out_tongue:

  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. :wink:

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

  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. :frowning:

and thanks for your understanding in the PM. =)

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:

:wink:

no problem… glad i could help. =)