i'm trying to script an interface for a flash site that uses a kind of mock 3D depth so some objects appear closer to the front than others. These objects all slide along a horizontal plane to leave only one of the five main sections in view at any one time.
Now the issue is that each of the 5 sections contains 4 objects (20 objects in total) and the pathing in the script is dynamic to increment the ._x position of each object. For this i run a while loop to initiate the the doMove function for each section incrementing the section variable each time, problem being that each time the doMove function runs it only runs the last section of the movie and bypasses all other four sections, it's like each time the section number increments it stops the previous function from working in some cases before it even starts to move. is there a way i can slow down the incrementation of the while loop? or any other suggestions on how i can achieve this effect.
I've uploaded an example of the motion at
http://www.pollen.com.au/temp/ (you can see that only the red boxes will move when you click the small black boxes)
source file can be downloaded from
http://www.pollen.com.au/temp/sliding_motion.zipthe script for this whole project is below:
onClipEvent (load) {
//DEFINE EASING MOTION FUNCTION
_global.easeInOutQuad = function (t, b, c, d) {
t /= d/2;
if (t < 1) return c/2*t*t + b;
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
//REFERENCES ALL MOVIE CLIPS TO BE CONTROLLED
var objects01:Array = new Array("logo", "logo", "logo", "logo", "logo");
var objects02:Array = new Array("quote01", "quote02", "quote03", "quote04", "quote05");
var objects03:Array = new Array("image01", "image02", "image03", "image04", "image05");
var objects04:Array = new Array("text01", "text02", "text03", "text04", "text05");
var gotoPos:Array = new Array(0, 250, 550, 750, 950);
//INVOKED WHEN MAIN NAV IS CLICKED, CYCLES THROUGH ARRAY AND MOVES ALL OBJECTS
_global.region = function(r){
t = 0;
while(t<=5){
doMove(t,r); // will currently only run the function on section 5 and not the first 4 sections.
t++;
}
};
//DOES ALL OBJECTS MOTION A:LOGO B:QUOTE C:IMAGE D:TEXT & CONTENT
doMove = function(m,r){
var i=0;
var thePosA = eval("_parent." + objects01[m] + "._x");
var thePosB = eval("_parent." + objects02[m] + "._x");
var thePosC = eval("_parent." + objects03[m] + "._x");
var thePosD = eval("_parent." + objects04[m] + "._x");
var theDifA = gotoPos[r] - thePosA;
var theDifB = (gotoPos[r] * 3) - thePosB;
var theDifC = (gotoPos[r] * 6) - thePosC;
var theDifD = (gotoPos[r] * 9) - thePosD;
trace("m="+m + " r="+r);
onEnterFrame = function(){
set("_parent." + objects01[m] + "._x" , easeInOutQuad(i,thePosA,th
eDifA,50))
;
set("_parent." + objects02[m] + "._x" , easeInOutQuad(i,thePosB,th
eDifB,50))
;
set("_parent." + objects03[m] + "._x" , easeInOutQuad(i,thePosC,th
eDifC,50))
;
set("_parent." + objects04[m] + "._x" , easeInOutQuad(i,thePosD,th
eDifD,50))
;
if (eval("_parent." + objects01[m] + "._x") == gotoPos[r]){
delete onEnterFrame;
var i=0;
} else {
i++;
}
};
};
}