Hi everybody, I’m currently trying to create something akin to a simple ‘page flip’ effect for a site.
The effect that I’m going for is basically a changing background, appearing by playing an MC (tweened movement of large rectangle that moves from off-screen to on-screen) that is, ideally, supposed to be executed by a button.
I currently have on the stage, four coloured buttons, with a corresponding MC off-stage that gets triggered by a button and slides on to take the place of the previous MC (background colours that slide in depending on which button you press). I also have a text box embedded in an MC which was basically just a test object that is supposed to stay on top of everything. The stack order should be [top]->[bottom], [text]->[buttons]->[background MCs]
The problem lies in the order of playing the MCs. A background colour rectangle MC should technically cover up whatever background MC is already there. However, when a new MC slides on, the one below it briefly changes to a seemingly random one. The MCs are currently not created dynamically, but I did ponder whether the problem could be solved by dynamically creating them using loadMovie and then removing it when the next one loads or something… I’ve made it work using swapDepths, but therein lies the problem I think, because swapDepths works by trading depths of MCs and, when giving the MC that you want to appear on top a certain depth, it takes that depth from an MC that already has it, thus causing THAT MC to adopt a new depth and the order seems to change completely… I considered using getNextHighestDepth(), but that obscures the text and, as I take it, getNextHighestDepth() gets THE highest possible depth (I think…), there doesn’t seem to be any meaning in assigning a depth, no matter how high, to the text.
I’m still learning AS, and was just hoping that someone more experienced could take a look at my problem…
Thanks in advance to anyone who answers, I’m attaching my .fla and here’s my script:
// MCs containing coloured buttons
// Plays each coloured button’s associated coloured page MC and swaps the MCs’
// depth bringing it to the top of the stack
btn1MC.btn1.onRelease = function(){
page1.gotoAndPlay(1);
page1.swapDepths(-6);
}
btn2MC.btn2.onRelease = function(){
page2.gotoAndPlay(1);
page2.swapDepths(-6);
}
btn3MC.btn3.onRelease = function(){
page3.gotoAndPlay(1);
page3.swapDepths(-6);
}
btn4MC.btn4.onRelease = function(){
page4.gotoAndPlay(1);
page4.swapDepths(-6);
}
// Corresponding swapDepths lines to place the coloured buttons (MCs containing
// the actual buttons to the top of the stack
btn1MC.swapDepths(-1);
btn2MC.swapDepths(-2);
btn3MC.swapDepths(-3);
btn4MC.swapDepths(-4);
// Swap depths for text box
Tbox.swapDepths(0);