|
Hi, all.
I'll show you some test code
about the closure.
You can see that 3 variables that is type of
Function were assigned with foo()
method.
Genually, as you know, the primitive types is passed by value
that is copied.
So I think that this is also.
How about you think?
private
function foo () : Function
{
var i:int = 0;
function rectArea() : int {
// function closure defined
return ++i;
}
return rectArea;
}
private
function bar () : void
{
var increaseCount1:Function
= foo();
var increaseCount2:Function
= foo();
trace("increaseCount1 : " +
increaseCount1() );
trace("increaseCount1 : " +
increaseCount1() );
var increaseCount3:Function
= foo();
trace("increaseCount2 : " +
increaseCount2() );
trace("increaseCount3 : " +
increaseCount3() );
trace("increaseCount1 : " +
increaseCount1() );
trace("increaseCount1 : " +
increaseCount1() );
trace("increaseCount2 : " +
increaseCount2() );
trace("increaseCount3 : " +
increaseCount3() );
}
bar();
//
Output
increaseCount1
: 1 increaseCount1 : 2 increaseCount2 : 1 increaseCount3 : 1 increaseCount1 : 3 increaseCount1 : 4 increaseCount2 : 2 increaseCount3 : 2 -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS
|
- [flexcoders] [FLEX2:B3] I think that a variable of the F... Bryan Choi
- Re: [flexcoders] [FLEX2:B3] I think that a variable... Till Schneidereit

