the Delegate class is useful whenever you are trying to control the
scope of a method call.  Normall, when you do something like:

//code on _root
my_mc.onPress = function(){
 trace(this);
}

the onPress function is assigned to my_mc.  this means that when you
use "this" inside code inside the onPress function, you will be
referring to my_mc (the code above would output "_level0.my_mc").
Most of the time, people will want to create a separate function to
run when the onPress event occurs (or when an onLoad event occurs in
an XML or LoadVars object).

//code on the _root timeline
my_mc.onPress = Delegate.create(this, myPressFunction);

function myPressFunction(){
 trace (this)
}

this code would output "_level0". This means that you can still run
the function in it's normal scope and still have normal references to
other variables and methods in the same scope.  This comes in most
handy whe you are dealing with classes, where you'd want to reference
methods and properties in your class when an event occurs, but you
don't want the mehod (such as onPress) being scoped to the object that
produced the event.



On 6/14/06, Andreas Rønning <[EMAIL PROTECTED]> wrote:
i use Delegate for most handlers. Never used it with components

- A

Stephen Ford wrote:

>Hello All,
>
>Can anyone confirm that the Delegate class is only helpful when using 
components ?
>
>Or should it also be used for events outside the component framework ?
>
>No doubt it depends on what your trying to achieve, but just generally 
speaking, what do you think.
>
>Thanks,
>Stephen.
>
> _______________________________________________
>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
>
>
_______________________________________________
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

_______________________________________________
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