I think that's just another example of "quick and dirty".
If your button needs a property "fruit" it should be a property of the class.
In other words, it should be its own class, eg FruitButton, with a property 
"fruit".

In AS2 I have never needed to pass any arguments to a Delegate, ever..
If you find you need to, you're doing something wrong and there's other (and 
better) ways of doing it.

In Flex, components have a data property of type Object that you can use.
It's main purpose is for components used as renderers, but if you feel like it, 
you can use it for other purposes as well.

function btnClickHandler(evt:MouseEvent):void {
    trace(evt.currentTarget.data.fruit);
}
var btn:Button = new Button();
btn.data = {fruit:"pineapple"};
btn.addEventListener(MouseEvent.CLICK, btnClickHandler);

However, I doubt FCS3 components will have that same data property, since item 
renderers are not a big part of the Flash Component 
Framework, at least not in the same way it is in Flex.

AS3 finally has an Event class, which can be easily extended.. Time to start 
using it ;-)

regards,
Muzak

----- Original Message ----- 
From: "Merrill, Jason" <[EMAIL PROTECTED]>
To: <flashcoders@chattyfig.figleaf.com>
Sent: Monday, April 09, 2007 8:12 PM
Subject: RE: [Flashcoders] AS3 Delegate


> However, in AS 2 to tack on variables, I did/do it differently:
>
> var myDel:Object = myButton.onRelease = Delegate.create(this,
> doFunction)
> myDel.fruit = "pineapple";
>
> function doFunction():Void
> {
> trace(arugments.caller.fruit)
> }
>
> I assumed in AS3 you could do something similar, though I don't know, I
> haven't tried yet:
>
> var myObj:Object = myButton.onRelease = doFunction
> myObj.fruit = "pineapple";
>
> function doFunction():Void
> {
> trace(arugments.caller.fruit)
> }
>
> Or no?  I kinda doubt you have to do it the way you posted on your blog,
> but I don't know for sure.  If you do, that really sucks.
>
>
> Jason Merrill


_______________________________________________
Flashcoders@chattyfig.figleaf.com
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