Very short trick: ADDED_TO_STAGE

giovedì 8 gennaio, 2009

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:

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

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

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

Post correlati

Questo articolo ti è stato utile?: Per nientePocoAbbastanzaMoltoMoltissimo
Loading ... Loading ...

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
[as][/as]           // Actionscript
[css][/css]         // CSS Style Sheet
[html][/html]       // HTML
[js][/js]           // Javascript
[objc][/objc]       // Objective-C
[php][/php]         // PHP
[sql][/sql]         // SQL