header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
thebes
Points:90
Posts:1
Answered

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.



1
Inder
Points: 2980
Posts:0
Accepted Answer
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

*/



Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 7+5 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions