Please activate JavaScript!
Please install Adobe Flash Player, click here for download

SAE Magazin 2/2011

This article is an introduction to AS3 Signals explaining how you can employ it to wire your objects with much less code than you would need when using native events. Dieser Artikel gibt dir eine Einführung in das Actionscript Framework AS3 Signals. Lerne wie deine Objekte effizient und mit weniger Quelltext kommunizieren können. AS3 Signals Think Outside the Event An Introduction to by Hendrik Maus Signals can make a developer’s life a whole lot easier by just being fast, efficient and easy to use. AS3 Signals macht das Entwicklerleben einfacher, schneller und effizienter. Was ist AS3 Signals? Es handelt sich hier um ein, von C# inpiriertes Framework zur Kommunikation zwischen Actionscript 3.0 Objekten ähnlich der nativen Flash Events. Mit AS3 Signals schreibt man jedoch deutlich weniger Code. Was ist ein Signal? Ein Signal ist vergleichbar mit einem Actionscript Event. Sig- nals benutzen jedoch keine Kanäle die auf Zeichenketten ba- sieren, sondern sind eine konkrete Eigenschaft einer Klasse. Als Actionscript Entwickler kennt man den aufwändigen Pro- zess zur Erstellung eigener Events. Man braucht eine neue Klasse die von der Event Klasse erbt etc. AS3 Signals erleich- tert dieses Vorgehen ungemein und versetzt den Entwickler trotzdem in die Lage all das zu tun was man mit nativen Flash Events erreichen kann. Das erste Signal Als erstes setzen wir ein Signal ein um ein eigenes Flash Event zu ersetzen. Wie bereits erwähnt sind Signale konkrete Eigen- schaften der Dispatcher-Klasse. Im Code-Beispiel fällt auf, dass unsere Klasse keinesfalls von der Flash Event Klasse erben muss. Das Signal ist eine simple öffentliche Eigenschaft von selbigem Typ. What is AS3 Signals?Basically AS3 Signals is a commu- nication framework much like the native events, but its concept is inspired by C# Signals. The main advantages of the framework are speed and less code. What is a Signal? Essentially a signal is a mini-dispatcher specific to one event. The basic concept of Signals is to not use string-based chan- nels, and to let the Signal be a concrete member of a class. If you are an ActionScript developer you may know the pro- cess of creating custom event classes in your projects. Defining constants, defining the event etc. Adding the listener, removing the listener and extending EventDispatcher in your dispatching class. Using Signals you can forget about that process, yet still be able to do everything that events can plus more. Letʼs have a look at the first type of signal. The Basic Signal Letʼs start with a basic signal you would make use of to replace a custom AS3 event. Put simply, a signal is an object that sits inside a public property of your dispatching class. The first thing we will see is that your dispatching class feels no need to extend EventDispatcher like it would have to if you were using native events. What is AS3 Signals? Basically AS3 Signals is a communication framework much like the native events, but its concept is inpired by C# 112 Production & Know How // WEB // AS3 Signals