flash cs5中命名空间中的接口方法newFrame错误

发布于 2024-10-06 20:14:29 字数 2505 浏览 3 评论 0原文

我试图让 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦年海沫深 2024-10-13 20:14:29

当你实现一个接口时,你必须实现该接口中定义的所有方法。在您的情况下,接口 ITuioListener 中定义的方法 newFrame() 尚未在 TuioExampleDrawingCursor 中实现。将 ITuioListener 中的 newFrame() 方法添加到 TuioExampleDrawingCursor 中,它应该可以工作。

以下是实现接口的类的示例:

package
{
    import com.Automobile;
    import flash.display.MovieClip;

    public class Main extends MovieClip
    {
        public function Main():void
        {
            init();

        }// end function

        private function init():void
        {
            var automobile:Automobile = new Automobile();

        }// end function

    }// end class

}// end package

在文档类 Main 中,导入类 Automobile,然后创建 Automobile 的实例。

package com
{
    import com.IDrivable;

    public class Automobile implements IDrivable
    {
        public function Automobile():void {}// end function

        public function startEngine():void
        {
            // start automobile's engine

        }// end function

        public function stopEngine():void
        {
            // stop automobile's engine

        }// end function

        public function accelerate():void
        {
            // accelerate automobile

        }// end function

        public function turn(p_dir:String):void
        {
            // turn automobile

        }// end function

    }// end class

}// end package

在 Automobile 类中,导入并实现了 IDriverable 接口。 IDrivable 中定义的startEngine()、stopEngine()、accelerate() 和turn() 方法均在Automobile 中实现。

package com
{
    public interface IDrivable
    {
        function startEngine():void

        function stopEngine():void

        function accelerate():void

        function turn(p_dir:String):void

    }// end interface

}// end package

在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:

package
{
    import com.Automobile;
    import flash.display.MovieClip;

    public class Main extends MovieClip
    {
        public function Main():void
        {
            init();

        }// end function

        private function init():void
        {
            var automobile:Automobile = new Automobile();

        }// end function

    }// end class

}// end package

In the document class Main, the class Automobile is imported and then an instance of Automobile is created.

package com
{
    import com.IDrivable;

    public class Automobile implements IDrivable
    {
        public function Automobile():void {}// end function

        public function startEngine():void
        {
            // start automobile's engine

        }// end function

        public function stopEngine():void
        {
            // stop automobile's engine

        }// end function

        public function accelerate():void
        {
            // accelerate automobile

        }// end function

        public function turn(p_dir:String):void
        {
            // turn automobile

        }// end function

    }// end class

}// end package

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.

package com
{
    public interface IDrivable
    {
        function startEngine():void

        function stopEngine():void

        function accelerate():void

        function turn(p_dir:String):void

    }// end interface

}// end package

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文