// defining a class called Light, which extends the MovieClip class class Light extends MovieClip { // a class variable var lightState; var arrayX; var arrayY; // the class constructor which gets called when you create an object // note: in this case, its called when you create a movieClip using attachMovie function Light() { this.lightState = false; this.onPress = function() { this.switchState(); _root.spotPress(arrayX, arrayY); } } // a class method that sets the light's position // note, it uses the movieClip's class variables _x and _y function init(xPos:Number, yPos:Number) { this._x = xPos; this._y = yPos; } // sets position in 2D array function arrayInit(aX:Number, aY:Number) { this.arrayX = aX; this.arrayY = aY; } // a class method sets the light's current state function setState(newState:Boolean) { lightState = newState; if (newState) this.gotoAndStop("on"); this.gotoAndStop("off"); } // a class method that switches the light's current state function switchState() { lightState = !lightState; if (lightState) this.gotoAndStop("on"); else this.gotoAndStop("off"); } }