Skip to main content
Known Participant
June 14, 2006
Question

Problems with swapDepths() function

  • June 14, 2006
  • 7 replies
  • 662 views
I am designing a flash program that takes a series of images and descpriptions from an xml file and then adds a movie
clip for each node to the stage based off of one template. The series of clips scrolls from left to right with the movement of the mouse and when hovered over, the images enlarge by 300%. All of that works just fine. What I'm having problems with is that when the movie clips enlarge they are always partially covered by the next movie clip. I've tried everything to swap the depths but nothing works. PLEASE HELP!
The movie clip 'picHolder_mc' w/ linkage 'template' is attached to holder_mc on the stage (this is generated by the number of xml nodes). picHolder_mc contains a movie clip of a button (which basically holds the area for the hover), a dynamic text field, a movie clip (imageHolder_mc) that the jpg is attached to and the background image to fill in the template.

So the tree would be someting like this:

(pic_btn, imageHolder_mc, and pic_txt)
> picTemplate (movie clip that groups the button, txt box, and imageHolder_mc)
> picHolder_mc ('template')
>holder_mc
>stage

This topic has been closed for replies.

7 replies

Known Participant
June 15, 2006
Craig Grummitt THANK YOU. Your advice worked perfectly. I thought that picHolder_mc was the parent clip but I guess not. Anyway, I can't thank you enough. I've spent about 10 hours trying to fix this.
Craig Grummitt
Inspiring
June 15, 2006
i wasn't referring to objects placed at authoring time - i was referring to "object created dynamically from script", specifically:
newPiece=holder_mc.attachMovie('template','piece'+i, i + 16384);

and aren't the objects placed at authoring time that begin at -16383 a negative depth?

anyway i'm out before i'm in this too deep.
Inspiring
June 15, 2006
"Craig Grummitt" <webforumsuser@macromedia.com> wrote in message
news:e6qe3h$g0q$1@forums.macromedia.com...
>i believe this is a pathing issue. The movie clip you attach from the
>library
> called 'template' is what you attribute the levels of 16383 and up right(i
> think you'll find they are positive and not negative depths - or was your
> hyphen, hecktic Design, an indicator rather than a negative sign? Actually
> while on the topic, why did you start the depths at 16383? -16383 is the
> edge
> of depths, but that doesn't mean you have to play on the edge!)

You don't seem to understand that object placed at authoring time have
depths starting from -16383 and go up. It is only object created
dynamically from script (or that have had their depth changed) that have
negative depth. Sounds like you may need to do some reading - don't want to
be out of your depth :):):)
--
Jeckyl


Craig Grummitt
Inspiring
June 15, 2006
i believe this is a pathing issue. The movie clip you attach from the library called 'template' is what you attribute the levels of 16383 and up, right?(i think you'll find they are positive and not negative depths - or was your hyphen, hecktic Design, an indicator rather than a negative sign? Actually while on the topic, why did you start the depths at 16383? -16383 is the edge of depths, but that doesn't mean you have to play on the edge!)

Anyway, the onClipEvents that you've said are 'ON THE MOVIE CLIP TEMPLATE' i suspect are actually attached to a movieclip inside the template movieclip(perhaps called 'picHolder_mc')? (i suspect this as you can't attach onclipevents directly to symbols in the library.) This would mean that the button which you said is 'INSIDE OF THE PARENT MOVIE CLIP'(that description didn't help much by the way!) would probably also be inside this movieclip? If these suspicions are correct then it would be the depth of this movieclip that would be being swapped in your code rather than the movieclip whose depth you want swapped - 'piece'+i.

Which is all a long way of saying, try this:
this._parent.swapDepths(20);
Inspiring
June 15, 2006
> What happens is that each one starts at -16383 and then after
> the this.swapDepths(20) changes to 20 and then stays there
> on all of them. So now if you go over them again they read
> 20 all the time, nothing seems to be swapping at all.

That what you told it to do .. you told it to put itself into depth 20 .. if
its already there, then calling it again will do nothing


Known Participant
June 15, 2006
Blemmo,
I have tried putting a trace on there, both before and after the swapDepths() function call. What happens is that each one starts at -16383 and then after the this.swapDepths(20) changes to 20 and then stays there on all of them. So now if you go over them again they read 20 all the time, nothing seems to be swapping at all. I've also tried using picHolder_mc.swapDepths(20) but there the output says undefined. I thought it should be picHolder_mc because that's the movie clip that is getting attached. I also used 20 just because the depths started at -16383.
Is it not working because I am using the same movie clip as the template for all of them?

here's the link to the swf so that you can get an idea of what I'm talking about as far as overlaying eachother.

http://www.heckelconstruction.com/test/gallery2.swf
Inspiring
June 14, 2006
Did you check the depth after swapDepths? It should be 20, from looking at your code. You can try this:

on (rollOver) {
this.xpos = 300;
this.ypos = 300;
this._rotation = 0;
this.swapDepths(20);
trace("new depth of "+this+": "+this.getDepth());
}

and see if it shows 20.
I don't understand why you set the depth to 20 when you want it to be in front. The MCs have depths starting at 16384, so the active MC needs a depth higher than that to be in front of the others, e.g. 20000.

greets,
blemmo