I can hit the first part; I'll leave the 2nd to someone else.
In Flash 8 and below, here's how you can tap into the framework using
MovieClip:
class Component extends MovieClip
{
// these functions are added at runtime by the mixin
// we define here so Flash compiler doesn't bitch
public var addEventListener:Function;
public var removeEventListener:Function;
private var dispatchEvent:Function;
// event dispatching power turn on... we get signal
static private var mixit:Void =
EventDispatcher.initialize(Component.prototype);
public function onPress():Void
{
var o:Object = {};
o.type = "pressSucka";
o.target = this;
dispatchEvent(o);
}
}
To use it, give the MC a linkage name, associate this class, and then:
import Component;
attachMovie("Component", "mc", 0);
mc.addEventListener("pressSucka", this);
function pressSucka(event:Object):Void
{
trace("pressed button, G!");
}
You get this for free extending UIObject:
import mx.core.UIObject;
class Component extends UIObject
{
public function onPress():Void
{
var o:Object = {};
o.type = "pressSucka";
o.target = this;
dispatchEvent(o);
}
}
In AS3, DisplayObject, Sprite, and MovieClip all extend EventDispatcher,
thus, they too already get dispatchEvent and friends for free.
----- Original Message -----
From: "Mark Ribau" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <[email protected]>
Sent: Friday, December 30, 2005 3:15 PM
Subject: [Flashcoders] Compoent Events Example (dispatch, listen, etc)
Does anyone know of a really really good example that shows how to write
Components that dispatch and listen to events ?
Deeper question: What about a Component that when dragged onto another
Component/Object adds listeners for that Component's Events to the
Component/Object ?
Any and all assistance is appreciated.
--
Mark Ribau
Lead Windows Developer | My Tech Blog
<http://www.redbugtech.com/blogs/mark.php>
Redbug Technologies, Inc. <http://www.redbugtech.com> - www.redbugtech.com
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders