0

I have a piece of code creating an instance of an object I call Line.

var velLine:Line;
if(/*some conditions*/)
    velLine = new Line(0, 0, x, y);

x and y are taken from an object in the program that represents a player (it's supposed to be a video game). They are of type Number.

The third line shown is throwing the error: 1067: Implicit coercion of a value of type Line to an unrelated type Class

Any idea what's causing this? BTW, the parameters for the Line constructor are all of type Number

EDIT: Some more code, hope this helps

//point for the center of the player
            var pCenter:Point = new Point(p.x + 38, p.y + 38);

            //First bounds check the endpoints
            //If you're hitting an endpoint, bounce off like it's a circle
            //return false in this case so that the program doesn't trigger 2 simultaneous collisions
            var velLine:Line, perpenLine:Line;
            if(distBetweenPoints(pCenter, new Point(l.x1, l.y1))){
                velLine:Line = new Line(0, 0, p.velVector.x, p.velVector.y);
                perpenLine:Line = new Line(l.x1 - 10, l.y1 - (-1 / velLine.m) * 10, l.x1 + 10, l.y1 + (-1 / velLine.m) * 10);
                operateCollision(p, perpenLine);
                trace("hit an end point");
                return false;
            }else if(distBetweenPoints(pCenter, new Point(l.x2, l.y2))){
                velLine:Line = new Line(0, 0, p.velVector.x, p.velVector.y);
                perpenLine:Line = new Line(l.x2 - 10, l.y2 - (-1 / velLine.m) * 10, l.x2 + 10, l.y2 + (-1 / velLine.m) * 10);
                operateCollision(p, perpenLine);
                trace("hit an end point");
                return false;
            }
avorum
  • 2,243
  • 10
  • 39
  • 49
  • http://curtismorley.com/2008/05/28/actionscript-error-1067-implicit-coercion-of-a-value-of-type-void-to-an-unrelated-type-function/ – Majid Laissi Jan 17 '13 at 23:38
  • How does this error apply to something being a class? – avorum Jan 18 '13 at 01:28
  • If you don't have the conditional in there, what happens? Can you provide more contextual code. I don't see enough there to even try to guess. – Amy Blankenship Jan 18 '13 at 01:53
  • I'm amazed this compiles. Your variable assignments are syntactically incorrect, type definitions should only be given when declaring a var. i.e. `velLine:Line = new Line()` should be `velLine = new Line()` – Creynders Jan 18 '13 at 08:33

0 Answers0