Hi,
i wudnt clutter everything with delegates and extra function creations when
its not needed:)

greetz
JC



On 7/16/07, Jesse Graupmann <[EMAIL PROTECTED]> wrote:

For variety sake, here is a simple alternative.


mx.events.EventDispatcher.initialize ( mc );

handleEvent ( mc, 'onPress' );
handleEvent ( mc, 'onRelease' );
handleEvent ( mc, 'onReleaseOutside' );

mc.addEventListener ( 'onPress', mx.utils.Delegate.create ( this,
eventHandler ) )
mc.addEventListener ( 'onRelease', mx.utils.Delegate.create ( this,
eventHandler ) )
mc.addEventListener ( 'onReleaseOutside', mx.utils.Delegate.create ( this,
eventHandler ) )

function handleEvent ( obj:Object, event:String )
{
       obj [ event ] = function(){this.dispatchEvent ({type:event,
target:this }) }
}

function eventHandler ( evt:Object )
{
       trace( evt.type + '\t\t\t' + evt.target );
}



_____________________________

Jesse Graupmann
www.jessegraupmann.com
www.justgooddesign.com/blog/
_____________________________



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Merrill,
Jason
Sent: Monday, July 16, 2007 10:23 AM
To: [email protected]
Subject: RE: [Flashcoders] Arguments.callee._name?

Slight typo in my last example, try this:

import mx.utils.Delegate

var oRel:Object = myButton_mc.onRelease = Delegate.create(this,
myButtonMethod)
var oRol:Object = myButton_mc.onRollOver = Delegate.create(this,
myButtonMethod)
oRel.name = "onRelease"
oRol.name = "onRollOver"

function myButtonMethod():Void
{
       trace(arguments.caller.name)
}

Basically you are assigning the delegate to an object, and then tacking
on a custom property to the object.

Curious though, why you need to do this?

Jason Merrill

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to