Dynamic Motion Simulating the Z-Axis

Ok, so, I’ve made a railroad track with actionscript. When it’s on the stage, it looks like you’re on the track, looking down it toward the horizon.

The full track consists of two elements: a MovieClip that is just one wooden plank, and a MovieClip that contains the two metal rails to lie on top of the planks (or ties).

Through a while loop, I’ve added all the planks I into an Array, with height, width, and y based on the previous plank added.

Now that they’re all on the stage, I’d like it to start moving, as if we are moving along the track. I’m finding it tricky to figure out exactly how to go about moving the y of each plank, along with resizing for it to show the vanishing point.

I know I’ll have to continually add another plank just below the edge of the stage, at the same time I’ll be removing a child at the horizon. I just don’t know how to do it. Can you guys help?

Thanks.

It goes a little something like this:
//===================================
import flash.display.MovieClip;
import flash.filters.;
import fl.transitions.Tween;
import fl.transitions.easing.
;

const stageWidth:int = 800;
const stageHeight:int = 456;
//total number of railroad ties to be added originally
var tieCount:int = 22;

//dimensions of the previous tie added – starting with the horizon
var lastTieY:Number = stageHeight / 5;
var lastTieHeight:Number = 1;
var lastTieWidth:Number = 30;

//maybe unnecessary. I thought maybe I’d need the height and y of the first tie placed
var firstTieY:Number = lastTieY;
var firstTieHeight:Number = lastTieHeight;

//this is how much larger each tie is from the previously added one
var sizeDiff:Number = 1.2;

//====Drop Shadow Filter variables======
var dsAngle:int = 45;
var dsColor:uint = 0;
var dsAlpha:Number = 1;
var dsBlur:Number;
var dsStrength:Number = .75;
var dsQuality:int = 1;
var dsInner:Boolean = false;
var dsKnockout:Boolean = false;
var dsHideObject:Boolean = false;
//======================================

var i:int = 0;

var railDS:DropShadowFilter = new DropShadowFilter(10, 45, 0, 1, 20, 20, .8, 1, false, false, false);

//current railroad tie
var currTie:MovieClip;
var tieArray:Array = new Array();

var goTrain:Tween;

function createTies(numberOfTies:int):void
{
// loop through the number of railroad ties
while(numberOfTies–)
{
//‘railroad’ is the name I assigned to the class representing the MovieClip for
//each tie when exporting for AS
currTie = new railroad();

    currTie.x = stageWidth / 2; //tie is centered horizontally on stage
    currTie.y = lastTieY + (lastTieHeight * Math.pow(sizeDiff,2));
    currTie.width = lastTieWidth * sizeDiff;
    currTie.height = lastTieHeight * sizeDiff;

    var currTieDS:DropShadowFilter = new DropShadowFilter(2 * lastTieHeight / currTie.height, dsAngle, dsColor, dsAlpha, currTie.height / 2, currTie.height / 2, dsStrength, dsQuality, dsInner, dsKnockout, dsHideObject);
    
    currTie.filters = [currTieDS];
    
    lastTieY = currTie.y;
    lastTieHeight = currTie.height;
    lastTieWidth = currTie.width;
    
    
    tieArray* = currTie;
    
    addChild(tieArray*);
    
    i = i + 1;
}

}

// Create the rail ties
createTies(tieCount);

var myRails:rails = new rails();

addChild(myRails);
myRails.y = firstTieY - firstTieHeight;
myRails.x = stageWidth / 2;

myRails.filters = [railDS];

function moveTies():void
{
/*tieArray.y = tieArray.y - 10;

    goTrain = new Tween(tieArray, "y", Regular.easeIn, tieArray.y, tieArray.y / sizeDiff, tieArray.height * sizeDiff, true); 

*/

}

moveTies();