From the Flex docs:
In general, the easiest way for a user-defined class to gain event dispatching capabilities is to extend EventDispatcher. If this is impossible (that is, if the class is already extending another class), you can instead implement the IEventDispatcher interface, create an EventDispatcher member, and write simple hooks to route calls into the aggregated EventDispatcher.
The above techniques make it possible include the core EventDispatcher functionality in your custom classes, but one thing to watch is that unless you explicitly register an EventListener on the instance the event is only available to the class, not the application.
Example: you have a class called myClass that extends EventDispatcher, and contains a method that dispatches an event myCustomEvent. In the application register an EventListener and handler with the object:
var myObject:myClass = new myClass();
myObject.addEventListener("myCustomEvent", myCustomEventHandler);
This allows the event to be captured by the application. If you want to limit the event scope to the class, add the listener and handler to the class directly. Thanks to Kieran for his help on this one
After trying and failing to overload a constructor in Flex, I had a look through the documentation and it turns out that you can’t overload at all in AS3 – one constructor per class only. What you can do though is use one of these workarounds – the first is to use default arguments in the constructor:
public function foo(arg1:Object = null, arg2:Object = null)
{
}
and the second is to use the (..rest) parameter:
public function foo(arg1:String, ...args)
{
}
Using either of these works fine, but they also prevent the compiler warning about any problems, so it’s a case of balancing risk with reward.
Follow-up to Flash Media Server 3 from [Ux]
Received an email from Wowza Media Systems today, announcing a significant price reduction which is presumably a direct response to the new FMS3 pricing – now the Wowza Pro Unlimited edition costs $995, which is an 80% drop. Some new features were announced too, including its own SecureToken anti-ripping protection and free upgrade to H.264 and HE-AAC once support for this is added (Q1 ‘08).
Adobe announced Flash Media Server 3 this week, now as a two-product line that includes the basic streaming server plus a new Interactive Media Server; this is really exciting news – Flash Player 9 with H.264 is now available and finally we can move away from Nellymoser ASAO and all the limitations it imposed. There are a number of other new features too – 128bit DRM via a new RTMPE protocol and HE-AAC audio are the headline features, but the new support for Flash Lite 3 is also welcome. It’s also just become much cheaper to adopt, with prices from $995 for the core server up to $4500 (the previous starting point) for the Interactive version.
So what does this mean for Wowza and Red5? At the moment things are actually looking very promising; the Wowza team seems confident that H.264 will be supported soon after FMS3 is released (January) and as before FMS3 is limited to Windows Server and RedHat only, with Actionscript on the server-side. The only thing missing now would be support for AMF3, which is quite important as AS3 is used increasingly for streaming application development. AMF0 still works of course, but native support would be much better overall.
Podcast recorders and HD video in web pages are now completely achievable, which makes me happy