Just the very simple class I usually use to start off most projects, by defining stage height and width, and not executing anything until the stage is initialized. This should be your document class.
/**
* Copyright RTLShadow ( http://wonderfl.net/user/RTLShadow )
* GNU General Public License, v3 ( http://www.gnu.org/licenses/quick-guide-gplv3.html )
* Downloaded from: http://wonderfl.net/c/jss7
*/
package {
import flash.text.TextField;
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite {
public function Main(){
addEventListener(Event.ADDED_TO_STAGE, init); // Adding the Event Listener so that we willl know when the stage is initialized.
}
public function init(e:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, init); // Removing the Event Listener for garbage collecting.
trace("Stage initialized. Ready to execute code.")
// Place all of your code here...
debug(); // You can ignore this. It's just to show that the init() is working.
}
public function debug():void{
var myTextField:TextField = new TextField();
myTextField.appendText("Stage Initialized. \n");
addChild(myTextField)
}
}
}