mmm still don't get the delegate concept
On 2/15/07, Muzak [EMAIL PROTECTED] wrote:
Look into the Delegate class -- mx.utils.Delegate
import mx.utils.Delegate;
class YourClass {
private var __rawHTML:String;
public function grabHTML():Void {
var html_data:LoadVars = new
So, the problem with your initial code is that the scope of the
function (what `this` refers to) is not your class, but instead is the
scope of the object it's being called on.
So, essentially your code is trying to call `html_data.doSomething()`,
which doesn't exist. You really want it to be
Incidentally, in AS3 all functions preserve their scope, so Delegate
is no longer needed. (Yay!) But, in the meantime, Delegate is the best
solution to the problem of associating a function call with a scope.
Also worth mentioning is that since static functions have no scope,
you don't need to
Hello Andrew,
public function grabHTML():Void {
var html_data:LoadVars = new LoadVars();
var grabber = this;
html_data.onData = function():Void {
grabber.doSomething();
};
Delegate!
import mx.utils.Delegate;
// ...
public function grabHTML():Void {
var html_data:LoadVars = new LoadVars();
html_data.onData = Delegate.create(this, doSomething);
html_data.load(http://somesite.ca/some.html;);
}
On 2/14/07, Andrew Murphy [EMAIL PROTECTED] wrote:
I'm
*goes to read up on Delegate*
Thank you. :)
-[a]-
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of T. Michael
Keesey
Sent: February 14, 2007 9:20 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] Problem with cascading functions within a class
Look into the Delegate class -- mx.utils.Delegate
import mx.utils.Delegate;
class YourClass {
private var __rawHTML:String;
public function grabHTML():Void {
var html_data:LoadVars = new LoadVars();
html_data.onData = Delegate.create(this, this.htmlDataHandler);
7 matches
Mail list logo