The whole point of a Delegate type class is to eliminate having to type
those 4 lines of code every time you want to handle an event from somwhere
else without messing up the scope.

-David R

On 6/14/06, Aaron Buchanan <[EMAIL PROTECTED]> wrote:

What is the difference between that and this:

class SomeClass {

    private var a:Number = 3;

    function SomeClass(mc:MovieClip){

        var thisObj = this;
        // Set a reference to "this"

        mc.onRelease = function(){

            thisObj.onRelease();
        }

    }

    function onRelease(){

        trace("this.a: "+this.a);

    }
}


On 6/14/06 1:39 PM, "js" <[EMAIL PROTECTED]> wrote:

> While not as elegant, you can get around this issue delegate-free with
> the following:
>
> class SomeClass {
>
> private var a:Number = 3;
>
> function SomeClass(mc:MovieClip){
>
> var thisObj = this;
> // Set a reference to "this"
>
> mc.onRelease = function(){
>
> thisObj.onRelease.call(thisObj);
> }
>
> }
>
> function onRelease(){
>
> trace("this.a: "+this.a);
>
> }
> }
>
> --
>
> Joseph
>
> James Marsden wrote:
>> The delegate class is a godsend for so many things...
>>
>>
>> // inside a class:
>>
>> mc.onEnterFrame = mx.utils.Delegate.create(this, main);
>>
>> function main()
>> {
>>    // the mc is calling my method, and I can access all my properties
as
>> if I was calling it myself
>> }
>>
>>
>>
>>
>> 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.
>>>
>>>

_______________________________________________
[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