开发者

Interface method newFrame in namespace error in flash cs5

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.*;
  impor开发者_开发技巧t 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜