In essence, if you’re trying to move two movieclips to perform depth then you can use setInterval along with getting the mouse position. In general I have one movieclip in the foreground, moving one way; and another moving the other direction.

Here’s all the code, but you can also download an FLA here:
http://www.designupdate.com/depth.zip

//Get the center of the stage
xStageCenter = Stage.width/2;
/*—————————————————————-
Functions
—————————————————————-*/
this.scrollmyForeground = function():Void {
//
//distanceToTravel is the mouse position minus the center of the stage.
//Right side = positive number.
//Left side = negative number.
//The closer the mouse is to the center, the slower it moves because there’s less added or subtracted.
distanceToTravel = this._xmouse-xStageCenter;
//Move the x position of myForeground(About section)
//Divide by 40 to slow down the animation.
myForeground._x -= distanceToTravel/100;
//If it’s too close to the left side, stop the movement.
if (myForeground._x<-100) { myForeground._x = -100; } else if (myForeground._x>200) {
myForeground._x = 200;
}
//Move the background video the opposite direction.
myBackground._x += distanceToTravel/150;
//If its’ too far to the left or right then stop it.
if (myBackground._x<-200) { myBackground._x = -200; } else if (myBackground._x>50) {
myBackground._x = 50;
}
};
/*—————————————————————-
Run Immediately
—————————————————————-*/
clearInterval(scrollInterval);
scrollInterval = setInterval(this, “scrollmyForeground”, 30);

Comments are closed.