SwapDepth help needed

Ok, I’ve got a guestbook made in flash that I just can’t quite get right. If someone seriously thinks that they can help, I’d apreciate greatly.\r\rWhat’s going on here is that I’ve temporarily set up the variables from a php script into a hub clip in the upper left corner. Mind you, that’s not the problem.\r\rI have a Movie clip called * page*, which contains another movie clip called “entry”, with an instance name of “entry”.\r\rWhen the movie is ready to do it’s stuff, it attaches * page* onto the main timeline calling it page0\r\rIt then duplicates it a number of times equal to number of rows it received from the variables that are getting loaded into it (-1 for the first one on page0). (for experimentation I’ve placed 3 fau entries into the hub.)\r\rSo I’ve got three movie clips of a page, instance names “page0”, “page1”, and “pag2”. These are located at a depth of 400, 401, and 402 as I wanted them out of the way of anything else. Each of these pages has an entry clip in it which has been given it’s variables from the hub clip back on frame 4.\r\rNow inside * page*, there is a tween in which the entry turns, like a page in a book, from right to left, spanning upwards a little for effect. In the middle of it’s movement, when it is almost vertical, it sends the playhead of entry to frame 2 which is blank. (tricky… so it looks like it’s only on one side:) ) Just in case you look at the file and see that, that’s what it is.\r\rLikewise when the page reaches this apex, it calls out to a function called\rswap(direction);\rwhich is supposed to take the page that is turning forward, and swap it to the bottem of the stack of "page"s. It also has animation for the other direction, calling the page to be placed on the top of the stack when it is turning from left to right.\r\rThe effect is screwed up somehow and I’m having trouble peicing it together.\r\rI think that my method of stacking the movie clips is inferior. Especially I’d like Pom or Suprabeener to take a look, and I don’t want to post it just for anyone to have. If you seriously think that you can figure out the problem then reply and I’ll email the file to you.

you can use swapDepths(nNumber) where ‘nNumber’ is not necessarily a depth with anything on it. so, if your depths are 400, 401, and 402 and you want to place the movie from depth 401 on the top you can do ‘swapDepths(403);’. if you wanted to send it behind, just do ‘swapDepths(399);’.\ryou could also create a function that would sort all the ‘pages’ at the same time.\rexample:\rfunction fSortDepth(aMovies,aDepths){\r// ‘aMovies’ is an array of references to movies.\r// ‘aDepths’ is a corresponding array of depths.\rfor(ii=1000;ii<aMovies.length+1000;ii++){\r// move the clips to depths that are out of the way.\raMovies[ii].swapDepths(ii);\r}\rfor(ii=0;ii<aMovies.length;ii++){\r// move the clips to the depths where they belong.\raMovies[ii].swapDepths(aDepths[ii]);\r}\r}\r// so, to call this function:\raClips=[_root.mcPage0,_root.mcPage1,_root.mcPage2];\raOrder=[403,401,402];\rfSortDepth(aClips,aOrder);\r// that will put the clips in this order:\r// _root.mcPage1 - depth of 401\r// _root.mcPage2 - depth of 402\r// _root.mcPage0 - depth of 403\r\rhope that helps!\r:) \rjeremy\r\rp.s. that function is scalable so you can have as many clips as you want.

I could try running it that way. I’ll give it a shot. At this point I’m ready to try anything

i’ve had similiar troubles. i ended up writing a few methods that will manage the depths for you … basically create a _depth property.\r\ri’ve put that here:\rmembers.shaw.ca/rlinton/eg/depths.html\r\rit’s not very pretty ;), but it shows you how it works.\r\rclick the square to create a movie, then you can drag them about, move them down or up a level, or move them to the bottom or top.\r\ryou can see the stack on the left.\r\rmind you, mx has now made it possible to query a movie as to its depth. there’s still a few abilities that these methods add; you can move a movie to a depth (vs swapping a movie’s depth), and you can ask what movie is in a particular depth.\r\ryou have to be careful not to adjust the depth or add movies without using the functions though, otherwise they get out of synch and the whole thing falls apart. as long as you stay within the framework though, it works great!

here’s a one-liner for ya:\rMovieClip.prototype._depth = function (nArgs) { this.swapDepths(nArgs);};\rthen, to set a movie clip’s depth:\r_root.mcMovie._depth(nNumber);\rwhere ‘nNumber’ is the desired depth.\r:) \rjeremy

wow\r\rI have a couple of functions that I had writen to take care of this stuff… but I must admit this script is very nice.\r\rI had origionaly been working with a depth array, but couldn’t get it to work correctly. I think that this will help me very much. Thank you.\r\rIf I have a question on this I’ll post back here.

sin,\r\ryou may as well write:\r\rMovieClip.prototype._depth = MovieClip.prototype.swapDepths;\r\rbut then, why bother? aside from saving a few keystrokes, i don’t see an advantage.

i didn’t see the advantage either, that’s why i wrote the function above. i’m all about saving keystrokes though!\r:) \rjeremy

no, i mean why bother writing the function at all. : )\r\rsince it just creates another way to call swapDepths.

no, the other function up there!! farther up!\r:) \rjeremy

In French, we call this un dialogue de sourd :lol: \rpom 0]

Thank you sooooo much Supra. You’re code is a dream of functionality.\r\rI’m using sections of it and changing them around for my usage… I almost had the whole thing completed when what should I see… but the page turning example in the Flash 5.0 forum … now I have to remake my animated pages to be at least that good.\r\rAh well… still working on it. Thanks for all the help.

upuaut - thanks. long live oop!\r\rsin - gotcha, that makes sense now. : )