class Robots { // global variables for timeline location and movie private var timeline:MovieClip; private var movie:MovieClip; //contstructor with parameters for reference to timeline and level //parameters are passed in from the fla file in for loop public function Robots(_timeline:MovieClip, level:Number) { //this timeline = _timeline; //level passed in as i from for-loop createGraphic(level); } // function to attach movie clip and give movement private function createGraphic(level:Number) { // random number (0,1,2,3) to choose a linked asset var graphic = Math.floor(Math.random()*2); // random numbers for position // note that Stage is global and view by all classes without declaration var posx = Math.floor(Math.random()*Stage.width); var posy = Math.floor(Math.random()*Stage.height); // attach the movieclips at random locations movie = timeline.attachMovie("robot"+graphic, "newrobot"+level, level, {_x:posx, _y:posy}); } }