Deprecated: Assigning the return value of new by reference is deprecated in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-settings.php on line 472

Deprecated: Assigning the return value of new by reference is deprecated in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-settings.php on line 487

Deprecated: Assigning the return value of new by reference is deprecated in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-settings.php on line 494

Deprecated: Assigning the return value of new by reference is deprecated in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-settings.php on line 530

Strict Standards: Declaration of Walker_Page::start_lvl() should be compatible with Walker::start_lvl(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_lvl() should be compatible with Walker::end_lvl(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::start_el() should be compatible with Walker::start_el(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_Page::end_el() should be compatible with Walker::end_el(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 594

Strict Standards: Declaration of Walker_PageDropdown::start_el() should be compatible with Walker::start_el(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 611

Strict Standards: Declaration of Walker_Category::start_lvl() should be compatible with Walker::start_lvl(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_lvl() should be compatible with Walker::end_lvl(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::start_el() should be compatible with Walker::start_el(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_Category::end_el() should be compatible with Walker::end_el(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 705

Strict Standards: Declaration of Walker_CategoryDropdown::start_el() should be compatible with Walker::start_el(&$output) in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/classes.php on line 728

Strict Standards: Redefining already defined constructor for class wpdb in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/wp-db.php on line 306

Deprecated: Assigning the return value of new by reference is deprecated in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/cache.php on line 103

Strict Standards: Redefining already defined constructor for class WP_Object_Cache in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/cache.php on line 425

Deprecated: Assigning the return value of new by reference is deprecated in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/theme.php on line 623

Strict Standards: Redefining already defined constructor for class WP_Dependencies in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/class.wp-dependencies.php on line 15
GP - What can wii do » Blog Archiv » Programmierung // EventListener
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 947

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 948

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 947

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 948

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 947

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 948

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 947

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 948

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 947

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 948

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 947

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 948

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 947

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /www/htdocs/w00c0b5d/ba-ma-gp2009/wp-includes/kses.php on line 948
Programmierung // EventListener - Christian Selent

Mit AS3 wurde das Konzept des Eventlisteners erweitert und es ersetzt einiges, was in AS2 grundlegend war. Eventlistener können an Objekte gehängt werden und haben die Funktion, das Eintreten bestimmter Ereignisse (wie Eingaben durch den Nutzer oder das Betreten eines Schlüsselbilds) zu überwachen. Treten die erwarteten Ereignisse ein, werden andere, festgelegte Ereignisse ausgelöst, was ungefähr dem Konzept des „on“ in AS2 entspricht.

Das Wiimote-Objekt besitzt auch einige dieser Eventlistener. Diese funktionieren so:

myWiimote.addEventListener( ButtonEvent.A_PRESS,
onAPressed );

myWiimote erhält den Eventlistener ButtonEvent.A_PRESS über die Methode addEventListener. Dieser fragt ab, ob der „A“-Button gedrückt wird. Tritt dieses Ereignis ein wird die Funktion onAPressed ausgelöst die dann folgendermaßen definiert werden könnte:

function onAPressed ( pEvt:ButtonEvent ):void {
trace(“A wird gedrückt”);
}

Es ist wichtig, dass bei der Funktionsdefinition darauf geachtet wird, welche Art von Ereignis eintritt, hier trat zum Beispiel mit pEvt:ButtonEvent,ein ButtonEvent ein. Dringend zu beachten ist, dass pEvt nur bei den Button- und den Wiimote- events eingesetzt wird. Bei den anderen wird pEvent geschrieben.

Die anderen Eventlistener können dann einfach an der Stelle, an der jetzt ButtonEvent.A_PRESS stand, eingefügt werden.

Folgende ButtonEvents sind noch möglich:

„A“ wird losgelassen

 ButtonEvent.A_RELEASE

„B“ wird gedrückt

 ButtonEvent.B_PRESS

„B“ wird gedrückt

 ButtonEvent.B_RELEASE

Das Steuerkreuz wird nach links, rechts, oben oder unten gedrückt

ButtonEvent.LEFT_PRESS, 
ButtonEvent.RIGHT_PRESS, 
ButtonEvent.UP_PRESS, 
ButtonEvent.DOWN_PRESS

Das Steuerkreuz wird links, rechts, oben oder unten losgelassen

ButtonEvent.LEFT_RELEASE,
ButtonEvent.RIGHT_RELEASE,
ButtonEvent.UP_RELEASE,
ButtonEvent.DOWN_RELEASE

Genauso funktioniert das bei der „Minus“-, der „Plus“, der „Home“-, der „1“- und der „2“-Taste

ButtonEvent.MINUS_RELEASE,
ButtonEvent.PLUS_PRESS,
ButtonEvent.PLUS_RELEASE,
ButtonEvent.HOME_PRESS
ButtonEvent.HOME_RELEASE,
ButtonEvent.ONE_PRESS,
ButtonEvent.ONE_RELEASE,
ButtonEvent.TWO_PRESS,
ButtonEvent.TWO_RELEASE

Hier treten die Ereignisse ein, wenn die Wiimote verbunden wurde, es dabei einen Fehler gab oder die Verbindung getrennt wurde.

Event.CONNECT,
IOErrorEvent.IO_ERROR,
Event.CLOSE

Bei diesem Eventlistener wird ein Ereignis ausgelöst, wenn von der Wiimote Daten empfangen werden. Das hat eine recht hohe Frequenz und kann somit als besserer Ersatz für Event.ENTER_FRAME verwendet werden.

WiimoteEvent.UPDATE