flash cs5中命名空间中的接口方法newFrame错误
我试图让 tuio 在 flash 中运行,但出现此错误:
第 10 行 1044:名称空间 org.tuio 中的接口方法 newFrame:ITuioListener 未由类 TuioExampleDrawingCursor 实现。
我不知道该如何修复它,因为我在长时间中断后正在重新学习 flash。这是其使用的代码:
package {
import org.tuio.*;
import org.tuio.osc.*;
import org.tuio.connectors.*;
import flash.display.*;
import flash.ui.*;
import flash.events.*;
public class TuioExampleDrawingCursor extends MovieClip implements ITuioListener {
private var circleSize:Number;
private var tuio:TuioClient;
public function TuioExampleDrawingCursor(){
this.circleSize = 10;
stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
/* Uncomment the connection type you want to use
* comment or remove the other one
* LocalConnection is the connection method used by default
*/
this.tuio = new TuioClient(new LCConnector());
this.tuio.addListener(this);
//this.tuio = new TuioClient(new TCPConnector());
//this.tuio.addListener(this);
}
public function handleKeyDown(event:KeyboardEvent):void {
if (event.keyCode == Keyboard.DOWN){
this.circleSize -= 2;
} else if (event.keyCode == Keyboard.UP){
this.circleSize += 2;
}
}
public function addTuioCursor(tuioCursor:TuioCursor):void {
new Circle(tuioCursor.sessionID.toString(), stage, tuioCursor.x*stage.stageWidth, tuioCursor.y * stage.stageHeight, this.circleSize, 0xee3333);
}
public function updateTuioCursor(tuioCursor:TuioCursor):void {
var currentCircle:Circle = stage.getChildByName(tuioCursor.sessionID.toString()) as Circle;
currentCircle.x = tuioCursor.x*stage.stageWidth;
currentCircle.y = tuioCursor.y*stage.stageHeight;
}
public function removeTuioCursor(tuioCursor:TuioCursor):void {
var currentCircle:Circle = stage.getChildByName(tuioCursor.sessionID.toString()) as Circle;
stage.removeChild(currentCircle);
}
public function addTuioObject(tuioObject:TuioObject):void {}
public function updateTuioObject(tuioObject:TuioObject):void {}
public function removeTuioObject(tuioObject:TuioObject):void {}
public function addTuioBlob(tuioBlob:TuioBlob):void {}
public function updateTuioBlob(tuioBlob:TuioBlob):void {}
public function removeTuioBlob(tuioBlob:TuioBlob):void {}
}
}
任何帮助将不胜感激。
i am trying to get tuio running in flash an i am getting this error:
Line 10 1044: Interface method newFrame in namespace org.tuio:ITuioListener not implemented by class TuioExampleDrawingCursor.
i'm not sure what to do about fixing it as i'm relearning flash after an extended hiatus. here is the code its used in:
package {
import org.tuio.*;
import org.tuio.osc.*;
import org.tuio.connectors.*;
import flash.display.*;
import flash.ui.*;
import flash.events.*;
public class TuioExampleDrawingCursor extends MovieClip implements ITuioListener {
private var circleSize:Number;
private var tuio:TuioClient;
public function TuioExampleDrawingCursor(){
this.circleSize = 10;
stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
/* Uncomment the connection type you want to use
* comment or remove the other one
* LocalConnection is the connection method used by default
*/
this.tuio = new TuioClient(new LCConnector());
this.tuio.addListener(this);
//this.tuio = new TuioClient(new TCPConnector());
//this.tuio.addListener(this);
}
public function handleKeyDown(event:KeyboardEvent):void {
if (event.keyCode == Keyboard.DOWN){
this.circleSize -= 2;
} else if (event.keyCode == Keyboard.UP){
this.circleSize += 2;
}
}
public function addTuioCursor(tuioCursor:TuioCursor):void {
new Circle(tuioCursor.sessionID.toString(), stage, tuioCursor.x*stage.stageWidth, tuioCursor.y * stage.stageHeight, this.circleSize, 0xee3333);
}
public function updateTuioCursor(tuioCursor:TuioCursor):void {
var currentCircle:Circle = stage.getChildByName(tuioCursor.sessionID.toString()) as Circle;
currentCircle.x = tuioCursor.x*stage.stageWidth;
currentCircle.y = tuioCursor.y*stage.stageHeight;
}
public function removeTuioCursor(tuioCursor:TuioCursor):void {
var currentCircle:Circle = stage.getChildByName(tuioCursor.sessionID.toString()) as Circle;
stage.removeChild(currentCircle);
}
public function addTuioObject(tuioObject:TuioObject):void {}
public function updateTuioObject(tuioObject:TuioObject):void {}
public function removeTuioObject(tuioObject:TuioObject):void {}
public function addTuioBlob(tuioBlob:TuioBlob):void {}
public function updateTuioBlob(tuioBlob:TuioBlob):void {}
public function removeTuioBlob(tuioBlob:TuioBlob):void {}
}
}
any help would be greatly apperciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当你实现一个接口时,你必须实现该接口中定义的所有方法。在您的情况下,接口 ITuioListener 中定义的方法 newFrame() 尚未在 TuioExampleDrawingCursor 中实现。将 ITuioListener 中的 newFrame() 方法添加到 TuioExampleDrawingCursor 中,它应该可以工作。
以下是实现接口的类的示例:
在文档类 Main 中,导入类 Automobile,然后创建 Automobile 的实例。
在 Automobile 类中,导入并实现了 IDriverable 接口。 IDrivable 中定义的startEngine()、stopEngine()、accelerate() 和turn() 方法均在Automobile 中实现。
在IDrivable接口中,定义了startEngine()、stopEngine()、accelerate()和turn()方法。
您不仅必须实现接口中的方法,而且相应的方法必须具有匹配的签名。这意味着它们必须具有相同的参数和返回类型。
When you implement an interface, you must implement all the methods defined in the interface. In your case, the method newFrame() defined in the interface ITuioListener has not been implemented in the TuioExampleDrawingCursor. Add the method newFrame() from ITuioListener to TuioExampleDrawingCursor and it should work.
The following is an example of a class implementing an interface:
In the document class Main, the class Automobile is imported and then an instance of Automobile is created.
In the class Automobile, the interface IDrivable is imported and implemented. The methods startEngine(), stopEngine(), accelerate() and turn() that are all defined in IDrivable are implemented in Automobile.
In the interface IDrivable, the methods startEngine(), stopEngine(), accelerate() and turn() are defined.
Not only must you implement the methods in the interface, the corresponding methods must have matching signatures. This means that they must have the same parameters and return types.