3/27/2010 10:41:36 AM
Title:
what are bound methods in AS 3.0?
Hi I am new to Actionscript
Please explain with relavent example
what are bound methods in As 3.0 and where they should be used.
Inder
Points: 2980
Posts:0
3/28/2010 8:19:04 AM
As the name implies bound methods are bound to there parent. Which means they execute with reference to parent in which they are defined. When executing a bound method it will always trace "this" as its class in which it is defined and not from where its called.
Bound methods are the methods that we pass as arguments to a function or the methods that are received as values from a function. Here is an example of bound method in ActionScript 3.0 to make it more clear:
class boundTest
{
private var returnString:String="This string is traced from bound method";
function boundFunction():void // bound method defined
{
trace("bound method is executed in: " + this);
trace(returnString);
}
function execBound():Function
{
return boundFunction; // bound function returned
}
}
var myBoundTest:boundTest= new boundTest();
var myFunc:Function = myBoundTest.execBound();
/*
trace output:
bound method is executed in:: [object boundTest]
This string is traced from bound method
*/