Ok I'm trying to draw a box with actionscript 3 and flex 3.5. First a few things:
1) I am not using any IDE at all, just notepad and flex 2) I am not using any mxml file at all (yes this is possible with as3 apparently) 3) I am not using inheritance ie I'm not using an extends on my classes, I'm trying to get this particular bit of code to work only through composition
Anyway this is the code itself (the file name is MAIN.as):
package
{
import flash.display.*;
import mx.core.Application;
import flash.events.*;
import mx.collections.*;
import flash.geom.*;
import mx.controls.*;
import flash.text.*;
import mx.events.*;
import mx.styles.*;
public class MAIN
{
public var APPLICATION:Application = Application(Application.application);
public function MAIN()
{
APPLICATION.layout = 'absolute';
var BOX:Sprite = new Sprite();
BOX.graphics.beginFill(0xFF0000,1);
BOX.graphics.drawRect(0,0,400,400);
BOX.graphics.endFill();
APPLICATION.addChild(BOX);
}
}
}
It compiles just fine but isn't displaying anything. I should see a red box but right now all I'm seeing is a blank screen. I've gotten this to work by using class MAIN extends Sprite and then getting rid of the box variable all together but again I want to avoid using the extends command. Sorry that the imports got kinda smooshed in the post, they aren't really relevant to the problem though so it doesn't matter all that much.