The this within the xmlOnload now points to the object you gave as scope to
the create method of delegate.

In order to access the xml object you would need to reference xmlDoc
instead.

The whole point of Delegate is to make sure mehods are called with the
correct scope. xmlOnLoad will be called with the scope it's defined on as
you call Delegate.create(this, xmlOnload).

I hope this explains it.


Greetz Erik


On 6/13/08, allandt bik-elliott <[EMAIL PROTECTED]> wrote:
>
> the delegate questions have kinda hijacked the other question i've asked so
> i'd like to have a separate discussion here if i can
>
> i've got a method that broadcasts a message to the instancing class but if
> i
> delegate it, it doesn't seem to work
>
> here is my original method with the anonymous function that works
> correctly:
>
>     private function getXML():Void
>     {
>         var ref = this;
>         xmlDoc.ignoreWhite = true;
>         xmlDoc.onLoad = function():Void
>         {
>             ref.broadcastMessage("ready");
>         }
>         xmlDoc.load(sPath);
>     }
>
>
> here is what i've tried to do to use the Delegate class instead:
>
>     private function getXML():Void
>     {
>         xmlDoc.ignoreWhite = true;
>         xmlDoc.onLoad = Delegate.create(this, xmlOnLoad);
>         xmlDoc.load(sPath);
>     }
>
>     private function xmlOnLoad():Void
>     {
>         trace(this); traces[object, Object] if next line is commented out
>         this.broadcastMessage("ready");
>     }
>
> i'd love to use this more but it seems there are a lot of hoops to jump
> through at the moment
>
> a
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to