Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starling.dispose() loses Gestouch swipe #89

Closed
sankar2389 opened this issue Sep 11, 2015 · 3 comments
Closed

Starling.dispose() loses Gestouch swipe #89

sankar2389 opened this issue Sep 11, 2015 · 3 comments

Comments

@sankar2389
Copy link

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

@fljot
Copy link
Owner

fljot commented Sep 11, 2015

Please try this branch https://github.com/fljot/Gestouch/tree/features/71-fix-initialization – I have refactored some initialization stuff – see changelog for instructions: https://github.com/fljot/Gestouch/blob/features/71-fix-initialization/CHANGELOG.md
I need some confirmation that it works=)

Don't re-do all this initialization stuff when you create another Starling instance. Setup input adapter and add display list adapter only once. And regarding hit-tester – just keep a reference to once created and added StarlingTouchHitTester and update starling reference there Oh snap StarlingTouchHitTester has no way to update starling property – it's set in constructor only... Well, then on dispose call:

Gestouch.removeTouchHitTester(this.myStarlingTouchHitTester);

and when create starling do:

this.myStarlingTouchHitTester = new StarlingTouchHitTester(this.starling);
Gestouch.addTouchHitTester(this.myStarlingTouchHitTester, -1);

@sankar2389
Copy link
Author

Thanks Fljot, now it works :)

@fljot
Copy link
Owner

fljot commented Sep 11, 2015

@sankar2389 and branch code – all good?

@fljot fljot closed this as completed Sep 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants