Search code examples
actionscript-3apache-flexgesturesstarling-framework

Gestouch is not working


I use starling for book reader app. When i change the book, i'm disposing the current starling and create new starling instance.But when I created new starling, Gestouch doesn't works.

How to restart gestouch for a new starling instance

gestouch code:

    gallery.addEventListener(MouseEvent.CLICK,book);

    onKeyDown(event:KeyboardEvent):void
    {
        if(event.keyCode == Keyboard.BACK )
        {
            event.preventDefault();
            event.stopImmediatePropagation();
            this.starling.stop();
            this.starling.dispose();
            this.starling = null;
        }
    }

    book(e:MouseEvent):void
    { 
        this.starling = new Starling(RacTestApp,stage,viewPort);
        Gestouch.inputAdapter ||= new NativeInputAdapter(stage);
        Gestouch.addDisplayListAdapter(starling.display.DisplayObject, new StarlingDisplayListAdapter());
        Gestouch.addTouchHitTester(new StarlingTouchHitTester(this.starling), -1);
        this.starling.start();
    }

thank you


Solution

  • Hey Guys I got the answer:

    OnKeydown(){
        Gestouch.removeTouchHitTester(this.myStarlingTouchHitTester);
    }
    
    book(){
        this.myStarlingTouchHitTester = new StarlingTouchHitTester(this.starling);
        Gestouch.addTouchHitTester(this.myStarlingTouchHitTester, -1);
    }
    

    We have to add and remove TouchHitTester, if we are using multiple starling instances.