¿Se ejecuta el código con cada nuevo objeto creado?

if i have following code :

class Stand {

public static const STAND_LIST:Array = new Array();
STAND_LIST[0] = new Array();
STAND_LIST[1] = new Array();

public function Stand() {
    //constructor
    }
}

is the STAND_LIST[0] keeps created every new instance of Stand created? or is it created just once?

if it's created every new instance of Stand created, how do i make it run just once?(like initializing const)

preguntado el 27 de agosto de 11 a las 15:08

Its static so just once for the Stand clase, Stand.STAND_LIST, but it won't be available for an instance of Stand, var stand:Stand = new Stand(); stand.STAND_LIST; // error. Also you might want to use this public static var STAND_LIST:Array = [[], []];. -

thx for the response!. now i know it is just run once from your comment and bedwyr -

1 Respuestas

Statics are initialized once for the class; they are not initialized each time a new class instance is created.

aquí está a helpful link regarding static initializers in ActionScript:

Esta SO Q&A briefly discusses when statics are initialized.

contestado el 23 de mayo de 17 a las 15:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.