public var myButton:Button = new Button();
myButton.label = 'My Button'; // this code must be in any function, for example in constructor
1 person found this helpful
Code in HTML is executed without any functions. But if you create something like class all code is in constructor or in functions.
AS is OO language, so all initializations should be in constructor. Outside you can only declare variables with or without initialization.