/* * Platform.as - the platform class for the platform game moving platform tutorial * Author: Stephen Harris, Kaiparasoft Ltd * */ class Platform extends MovieClip{ // the direction the platform is currently moving, only relevant if movPlat == true var dirn; // the boundaries to the platforms movement var leftMost; var rightMost; // this flag determines in the game if this particular platform instance is a moving one var movPlat:Boolean = false; // the speed at which the platform moves if its a moving one var linearSpeed:Number; // constructor - empty function Platform(){ } // update function called every frame only if the platform is a moving one function Update(){ // switch direction when the platform reaches its limits if(_x > rightMost){ dirn = -1; } if(_x < leftMost){ dirn = 1; } // update its position based on direction and speed _x += linearSpeed*dirn; } }