Struggling with Drawing Graphics on a Sprite

I’m working on the layout of my OpenFL application and I’ve written some code to section out my screen into four sprites. I’ve drawn a brightly coloured rectangle over each and added them to the display list, but when I run my application all I get is a blank screen. I don’t get any errors and I don’t know what I could be doing wrong. Here’s the class if anyone else wants to take a look at it and see why it might not be working. I’ll keep trying to figure it out on my own in the mean time.


import openfl.display.Sprite;
import openfl.geom.Rectangle;
import openfl.Lib;
import openfl.text.TextField;
import openfl.text.TextFieldAutoSize;


  • @author Arthur Payne

class Main extends Sprite

private var statusBar:Sprite;
private var graphicsBar:Sprite;
private var mainArea:Sprite;
private var scrollBar:Sprite;
private var buttonBar:Sprite;

public function new()

      // Layout //
  statusBar = new Sprite();
  statusBar.x = 0;
  statusBar.y = 0;
  statusBar.width = stage.stageWidth / 5;
  statusBar.height = stage.stageHeight;
  graphicsBar = new Sprite();
  graphicsBar.x = statusBar.width;
  graphicsBar.y = 0;
  graphicsBar.width = stage.stageWidth - graphicsBar.x;
  graphicsBar.height = stage.stageHeight / 4;
  mainArea = new Sprite();
  mainArea.x = statusBar.width;
  mainArea.y = graphicsBar.height;
  mainArea.width = stage.stageWidth - statusBar.width;
  mainArea.height = stage.stageHeight * 0.375;
  buttonBar = new Sprite();
  buttonBar.x = statusBar.width;
  buttonBar.y = mainArea.y + mainArea.height;
  buttonBar.width = graphicsBar.width;
  buttonBar.height = stage.stageHeight - (mainArea.height + graphicsBar.height);;, 0, statusBar.width, statusBar.height);;;, 0, graphicsBar.width, graphicsBar.height);;;, 0, mainArea.width, mainArea.height);;;, 0, buttonBar.width, buttonBar.height);;



Since you have nothing in your sprite, setting it’s width and height will still result in them being 0 because they represent’s the width and height of the content in your sprite(which is currently nothing). I suggest that you use variables to store the dimension you want or just simple use numbers in the draw commands.

Oh! I forgot about that. Thank you very much!

No problem, good luck with your projects :smile: