MouseEvent Problem - Error #1006: setType is not a function

Hello everyone. I apologize that my first post on these forums is an Actionscript newbie question.

I’ve done some coding in AS2 and have been trying to make the transition into AS3, but I’m having trouble with a simple piece of code. I’ve appropriated and slightly altered the majority of this code from an Actionscript 3.0 tutorial that I’m following, but it doesn’t work correctly.

The main timeline has the following code. The idea is to create a series of movieclips that can be individually clicked to change their current frame.

var landLevel:Sprite = new Sprite();
landLevel.x = 0;
landLevel.y = 0;

//Number of land pieces to create.
var numLand:int = 30;
//Keep track of which land piece is being manipulated.
var currentLand:int = 0;
//Create the array for the land pieces.
var aLand:Array = new Array();
//When the land is clicked, change it to the next land type.
var nextLandType:int = 2;
//Total number of land types.
var totalLandTypes:int = 3;

//var aLand:Land = new Land(i)
//Draw the initial land pieces.
function drawLand(){
    //Loop through the number of land pieces to create.
    for (var i:int = 0; i < numLand; i++){
        aLand* = new Land(i);
        aLand*.x = 32+(i*64);
        aLand*.y = 256;
        landLevel.addChild(aLand*)//.name = "land"+i;
        //getChildByName("land"+i).addEventListener(MouseEvent.CLICK, clickLand);
        aLand*.addEventListener(MouseEvent.CLICK, clickLand);


function clickLand(evt:MouseEvent):void {
    nextLandType =;
    if (nextLandType > totalLandTypes){
        nextLandType = 1;

When I publish the .fla and click a movieclip instance, it traces: “undefined,” and “instanceX,” with X being a number (a multiple of 5). It doesn’t change the current movieclip frame, and throws the following error -

TypeError: Error #1006: setType is not a function.
at hc_levelEditor_fla::MainTimeline/clickLand()

Here’s my class (

//Declare a package so that there can be multiple classes within it.
package {
    //Import all the classes already defined by flash.
    import flash.display.MovieClip;
    //Declare a public class.
    public class Land extends MovieClip {
        public var index:int;
        public var type:int;
        //Add a constructor.
        function Land(i:int):void {
            //Store the index value.
            this.index = i;
            //Set the type as a flat piece of land to start.
        //Change the land piece to a particular type.
        public function setType(frame:int) {
            this.type = frame;

I can’t for the life of me figure out what is wrong. Any help would be greatly appreciated.