Very short trick: ADDED_TO_STAGE

Come abbiamo visto più volte, nel costruttore di una classe che estende un MovieClip può essere necessario aggiungere l’evento ADDED_TO_STAGE per capire quando il nostro MovieClip è disegnato effettivamente sulla stage:

1
2
3
4
// costruttore
public function MyClass():void {
    addEventListener( Event.ADDED_TO_STAGE, main );
}

Sarebbe buona norma eliminare tale evento all’interno della funzione main():

1
2
3
4
5
6
7
8
9
// costruttore
public function MyClass():void {
    addEventListener( Event.ADDED_TO_STAGE, main );
}
//
private function main( e:Event = null ):void {
    removeEventListener( Event.ADDED_TO_STAGE, main );
    // ...
}

Non ci sono commenti per questo Post

Lascia un commento

TAG XHTML PERMESSI: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERIMENTO CODICE:
<pre></pre> // blocco generico
					<code></code> // blocco generico
					[cc_actionscript][/cc_actionscript] // Actionscript
					[cc_actionscript3][/cc_actionscript3] // Actionscript 3
					[cc_css][/cc_css] // CSS Style Sheet
					[cc_html][/cc_html] // HTML
					[cc_js][/cc_js] // Javascript
					[cc_objc][/cc_objc] // Objective-C
					[cc_php][/cc_objc] // PHP
					[cc_sql][/cc_sql] // SQL


Stop SOPA