Tema: scroll
Ver Mensaje Individual
  #6 (permalink)  
Antiguo 14/08/2006, 10:58
mon45
 
Fecha de Ingreso: agosto-2006
Mensajes: 8
Antigüedad: 17 años, 8 meses
Puntos: 0
Esto es lo que tengo en el primer frame:
function getStartingDims(){
if (myVar == undefined){
boxWidth = box_cont.box1._width; // Get the width of box1 inside our containerMC
box2X = box_cont.box2._x; // Getting our box2's x value;
gap = box2x - boxWidth; // the Gap between 2 boxes is the 2nd box's x value - the width of a box
totalDistance = gap + boxWidth; // distance of the gap + a width
startX = box_cont._x; // Get the Starting X position of box_cont
farthestX = box_cont.box6._x ; // Find out what the farthest point is we want to go, I actually messed up and in the script I had to go farthestX - totalDistance to make it work right.
myVar = 1; // Make it so It only sets this function on the Very First Frame
}
}

arrow_right.onRelease = function() {
if (Math.floor(box_cont._x) > Math.floor(((-1) * farthestX) + totalDistance) ){ // By using Math.floor it rounds it down for us, making decimals a lot easier to work with
_root.direction = "right"; // For frame 2, tells us which function to use
_root.xDest = box_cont._x - totalDistance; // Tells us what the destination is that we are going to next
gotoAndPlay(2); // We play our functions in a loop between frames 2 and 3
}
}
arrow_left.onRelease = function() {
if (box_cont._x < startX ){ // Check to make sure its not less than our starting x value
_root.direction = "left"; // For frame 2, tells us which function to us
_root.xDest = box_cont._x + totalDistance; // Tells us what the destination is that we are going to next
gotoAndPlay(2); // We play our functions in a loop between frames 2 and 3
}
}
function moveLeft(){
if (Math.floor(box_cont._x) != Math.floor(_root.xDest)){ // Again check using Math.floor to make sure we can still loop the movement
myDistance = (_root.xDest - box_cont._x); // This is our distance for our destination to our current x value
myJump = Math.sqrt(myDistance); // For a smooth transition, we use Math.sqrt function so that it goes really fast then slows down
box_cont._x += myJump; // Tells box_cont to move in the increment of myJump
}else{
gotoAndStop("anchored"); // stop at Frame 1
}
}
function moveRight(){
if (Math.floor(box_cont._x) != Math.floor(_root.xDest)){
myDistance = (box_cont._x - _root.xDest);
myJump = Math.sqrt(myDistance);
box_cont._x -= myJump;
}else{
gotoAndStop("anchored");
}
}

Y esto en otro pero de la segunada capa:
getStartingDims(); // Call our function to get us starting variables, such as x position
stop();

esto en el segundo frame:
if (_root.direction == "right"){
moveRight(); // When our right arrow is pushed, call our moveRight function in frame 1
}else if (_root.direction == "left"){
moveLeft(); // When our left arrow is pushed, call our moveLeft function in frame 1
}
Y esto en el tercero:
gotoAndPlay(2); // Loop to continue movement