Cannot use Graphics because it has no methods

So I have the following code:

using openfl.display.BitmapData;
using openfl.display.Graphics;
public function drawVerticalLine(x:Float, starty:Float, endy:Float, color:Int){
	Graphics.lineStyle(1, color);
	Graphics.moveTo(x, starty);
	Graphics.lineTo(x, endy);

It doesn’t compile. I get the following errors:

Class<openfl.display.Graphics> has no field lineStyle
Class<openfl.display.Graphics> has no field moveTo
Class<openfl.display.Graphics> has no field lineTo

This is strange. These methods exist in the docs. They exist in the openfl code. Why can’t I access them?

Those are instance methods, not static methods. They can me accessed through a DisplayObject instance (ex: Shape, Sprite, etc), which is added to the stage, and use like, color);
Hope that helps.

1 Like

Ah, right, I didn’t catch that in the documentation. Thanks!