Help with a super statement!!!

Hey everyone.

I am following along with the kerp.net tutorials on box 2d and in his code for the AbriStaticActor (a class) he has put a super. I keep getting this error:

\ArbiStaticActor.as:24: 1007: A super statement can be used only inside class instance

Now he has done it and it is working fine so how come when I go to do it it has this error.

This is the snippet of the code:

public function ArbiStaticActor(parent:DisplayObjectContainer, location:Point, arrayOfCoords:Array);
{
var myBody:b2Body = createBodyFromCoords(arrayOfCoords, location);
var mySprite:Sprite = createSpriteFromCoords(arrayOfCoords, location, parent);

super(mySprite, myBody);
}




So could someone please help.
Also I have this other error were it keeps saying on line 98 :expecting rightbrace before end of program when there is no line 98 of code and I already have the brace correct.

EXAMPLE of my braces at the end of the program:

return arbiBody;


}

}

}



So could someone please help.

Thank You.
For starters, what language are you using? It doesn't seem to be C++, which is the native language of Box2D and the language the main forums are dedicated to. There's a couple of sub forums for the ports, you might find better help there concerning your specific programming language.
First, make sure that ArbiStaticActor is actually the name of the class whose constructor you're using this call inside of - you can't call super(...) if you're not in a constructor, and that error is telling you that you're trying to.

Second, I'm not sure, but maybe in AS3 the super call has to come before any other method calls? That's the way it is in Java, at least, in which case you'd want to inline those creations like:

Code:
super(createSpriteFromCoords(arrayOfCoords, location, parent), createBodyFromCoords(arrayOfCoords, location));
In AS3 there is no problem in putting the super statement far below the constructor.

I see you have been looking into Todds tutorials 😛


The problem that I think you have is that the ArbiStaticActor is a static class, with some static methods or variables, so you can't call a super when you never instantiate that class.

Are you sure that the ArbiStaticActor extends Actor?
Code:
public class ArbiStaticActor extends Actor
{
    // A bunch of nonsensical Jibbrish :P
}



Hope it helps!!
hmm, I may be wrong but it seems to me that your problem is actually simpler than it looks. You have a semi-colon at the end of your constructor's declaration.

Code:
public function ArbiStaticActor(parent:DisplayObjectContainer, location:Point, arrayOfCoords:Array); <---- HERE
{
var myBody:b2Body = createBodyFromCoords(arrayOfCoords, location);
var mySprite:Sprite = createSpriteFromCoords(arrayOfCoords, location, parent);

super(mySprite, myBody);
}

Original thread: https://box2d.org/forum/viewtopic.php?t=5298