Skip to main content

on*** events

2 replies [Last post]
porfirioribeiro
Offline
Joined: 2006-08-18
Points: 0

Is there a way to access to the "this" variable when doing a node?

MyNode{
onKeyPressed:function(e:KeyEvent):Void {
//i want to acess to this node variables and functions
//it should be possible todo
//somefunc(); or this.somefunc();
}
}

if i have to assign MyNde to a var to be able to use its functions, we loose the wole concept of the language :s

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexsch
Offline
Joined: 2007-07-12
Points: 0

It is a known issue: JFXC-427 Replacement syntax for var: self
http://javafx-jira.kenai.com/browse/JFXC-427

The only way now is using a variable:
[code]
def myNode:MyNode = MyNode{
onKeyPressed:function(e:KeyEvent):Void {
myNode.somefunc();
}
}
[/code]

porfirioribeiro
Offline
Joined: 2006-08-18
Points: 0

Will this be fixed in the future?
Its really a bad behavior and destroys the point of a declared variable :(

Theres some wheird behaviores

class Test{
public var a:Integer=0;
public var action:function();
}
var test=Test{
var b:Integer=0;
action:function(){
a++;//error
b++;
}
}
test.a++;
test.b++;//error