可以这样做吗?
stage.addEventListener(TouchEvent.TOUCH_END, finish);
private function new(e:TouchEvent):void {
function finish(e:TouchEvent):void {
}
}
由于
答案 0 :(得分:2)
首先,strille是正确的,你的finish()函数应该驻留在new()函数之外。您要传输的变量可以存储在对象的属性中,然后在finish()函数中引用它们。另外,我不敢将你的函数命名为“new”,因为它在Actionscript 3中已经有了意义。
private function newTouch(e:TouchEvent):void {
touchedAtX=e.localX;
touchedAtY=e.localY;
// store more if you want to
}
private function finish(e:TouchEvent):void {
// here you can use your touchedAtX and touchedAtY stored values,
// as well as anything else
}
答案 1 :(得分:0)
不,内部finish()函数在外部new()函数之外不可用/可见。问题是为什么finish()需要在new()中定义,并且不能驻留在它之外?
private function new(e:TouchEvent):void {
finish(e);
}
private function finish(e:TouchEvent):void {
}