# 1026: Constructor functions must be instance methods

**URL:** <https://forum.kirupa.com/t/1026-constructor-functions-must-be-instance-methods/331726>\
**Category:** Uncategorized\
**Created:** [October 7, 2013, 2:08am UTC](https://forum.kirupa.com/t/1026-constructor-functions-must-be-instance-methods/331726 "2013-10-07T02:08:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![monomega](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@monomega](https://forum.kirupa.com/u/monomega)\
**Post date:** [October 7, 2013, 2:08am UTC](https://forum.kirupa.com/t/1026-constructor-functions-must-be-instance-methods/331726/1 "2013-10-07T02:08:44Z")

</div>

I’m working on a platform game and I wan the main character to shoot, I’m very new to Flash and ActionScript; this is ActionScript 3.0. I’ getting:“1026: Constructor functions must be instance methods.” when try to test my game, I don’t know if I have to import a class or what the problem is. The “blasts” are scripted using code from an example I also realize that the blasts are currently coded to shoot vertically I just wanted to able to get this character to shoot. Any help with this is greatly appreciated; below is the code: (I can post the fla. file if that would help)

stage.focus=stage;  
matazon.gotoAndStop(“stand”);  
var shootBlast:Boolean=false;  
var blastArray:Array=new Array(blast0,blast1,blast2,blast3,blast4,blast5);  
var blastIndex:int=-1;  
var moveRight:Boolean=false;  
var moveLeft:Boolean=false;  
var gravity:Number=2;  
var velocity:Number=1.1;  
var jumpPower:Number=0;  
var isJumping:Boolean=false;  
var ground:Number=630-matazon.height;  
var droneDirection:Number=5;  
var matazonScale:Number=matazon.scaleX;  
import flash.ui.Keyboard;  
stop();

stage.addEventListener(Event.ENTER\_FRAME, blastAnimation);  
stage.addEventListener(Event.ENTER\_FRAME, runAnimation);  
stage.addEventListener(Event.ENTER\_FRAME, leftWall);  
stage.addEventListener(Event.ENTER\_FRAME, rightWall);  
stage.addEventListener(KeyboardEvent.KEY\_DOWN, jump);  
stage.addEventListener(Event.ENTER\_FRAME, nojump);  
stage.addEventListener(KeyboardEvent.KEY\_DOWN, downKey);  
stage.addEventListener(KeyboardEvent.KEY\_UP, upKey);  
stage.addEventListener(Event.ENTER\_FRAME, moveOver);  
stage.addEventListener(Event.ENTER\_FRAME, matazonFunction);  
stage.addEventListener(Event.ENTER\_FRAME, droneLeft);  
stage.addEventListener(Event.ENTER\_FRAME,checkCollision);

function checkCollision(event:Event) {  
if (matazon.hitTestObject(drone)) {

```
    stage.removeEventListener(Event.ENTER_FRAME, blastAnimation);
    stage.removeEventListener(Event.ENTER_FRAME, runAnimation);
    stage.removeEventListener(Event.ENTER_FRAME, leftWall);
    stage.removeEventListener(Event.ENTER_FRAME, rightWall);
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, jump);
    stage.removeEventListener(Event.ENTER_FRAME, nojump);
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, downKey);
    stage.removeEventListener(KeyboardEvent.KEY_UP, upKey);
    stage.removeEventListener(Event.ENTER_FRAME, moveOver);
    stage.removeEventListener(Event.ENTER_FRAME, matazonFunction);
    stage.removeEventListener(Event.ENTER_FRAME, droneLeft);
    stage.removeEventListener(Event.ENTER_FRAME,checkCollision);
    removeChild(drone);
    gotoAndStop("endgame");
}

```

}

if (event.keyCode==Keyboard.B) {  
shootBlast=false;  
}

function blastAnimation(event:Event) {  
for (var i:int = 0; i \< 6; i++) {  
if (blastArray\*.y\<matazon.y) {  
blastArray\*.y-=10;  
if (blastArray\*.y\<0) {  
blastArray\*.x=i_70+100;  
blastArray_.y=595;

```
        }
    }
}

```

}

function runAnimation(event:Event) {  
if (moveRight==true &&(matazon.currentFrame == 14)) {

```
    matazon.gotoAndStop(2);

} else {

    matazon.gotoAndStop(matazon.currentFrame+1);

}

```

}

function rightWall(event:Event) {  
if (matazon.x\<25) {  
matazon.x=25;  
}  
}

function leftWall(event:Event) {  
if (matazon.x\>775) {  
matazon.x=775;  
}  
}

function jump(event:KeyboardEvent) {  
if (event.keyCode==Keyboard.SPACE &&(!isJumping)) {  
jumpPower=25;  
isJumping=true;

```
}

```

}  
function nojump(event:Event) {  
if (isJumping) {  
matazon.y-=jumpPower;  
jumpPower-=2;  
}

```
if (matazon.y+gravity&lt;ground) {
    matazon.y+=gravity;
    matazon.gotoAndStop("jump");
} else {
    matazon.y=ground;
    isJumping=false;

}

```

}

function matazonFunction(event:Event) {  
gravity\*=velocity;  
matazon.y+=gravity;  
if (matazon.hitTestObject(floor)) {

```
    velocity=0;

} else {

    velocity=1.1;

}

```

}

function droneLeft(event:Event) {  
drone.x=drone.x+droneDirection;  
if ((drone.x \< 75) || (drone.x \> 725)) {  
droneDirection=- droneDirection;  
drone.scaleX=- drone.scaleX;  
}  
}

function downKey(event:KeyboardEvent) {  
if (event.keyCode==Keyboard.RIGHT) {  
moveRight=true;  
}  
if (event.keyCode==Keyboard.B&&shootBlast==false) {  
shootBlast=true;  
blastIndex++;  
if (blastIndex\>5) {  
blastIndex=0;  
}  
var blast:blast=blastArray[blastIndex];  
blast.x=matazon.x;  
blast.y=matazon.y-1;

```
}
if (event.keyCode==Keyboard.LEFT) {
    moveLeft=true;
}

```

}

function upKey(event:KeyboardEvent) {  
if (event.keyCode==Keyboard.RIGHT) {  
moveRight=false;  
}  
if (event.keyCode==Keyboard.B) {  
shootBlast=false;  
}

}

if (event.keyCode==Keyboard.LEFT) {  
moveLeft=false;  
}

function moveOver(event:Event) {  
if (moveRight==true) {  
matazon.x+=20;  
matazon.scaleX=matazonScale;  
} else {

```
    if (moveLeft==true) {
        matazon.x-=20;
        matazon.scaleX=- matazonScale;
    } else {
        matazon.gotoAndStop("stand");
    }

}

```

}
