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

How can I use this scroll? #4

Open
ghost opened this issue Oct 23, 2014 · 3 comments
Open

How can I use this scroll? #4

ghost opened this issue Oct 23, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented Oct 23, 2014

Hi, Pavel!

Yesterday, I'm started to use your TouchScrolling library, but I still can't understand, how to work with it correctly. Could you help, please?

I have a Sprite in a FlashDevelop project and I want to scroll it.
I use the code:

private var touchScroller:TouchScrollModel;
...
touchScroller = new TouchScrollModel();
touchScroller.setViewportSize(stage.stageWidth, stage.stageHeight);

What should I do next? How to link sprite with touchScroller?

I've also tried to use TouchScroller class as follows:

private var touchScroller:TouchScroller;
...
touchScroller = new TouchScroller();
addChild(touchScroller);

and have few errors:

  • TouchScrollManager.as(1797): col: 57 Error:
  • TouchScrollManager.as(1816): col: 40 Error:
  • TouchScrollManager.as(1857): col: 41 Error:
  • TouchScrollManager.as(1903): col: 38 Error:
    Type was not found or was not a compile-time constant: PanGestureEvent.

Please, support me, how can I correctly use your TouchScroller library?

Thanks in advance!

@fykyx521
Copy link

https://github.com/fljot/Gestouch PanGestureEvent

At 2014-10-23 21:37:45, "soniko" [email protected] wrote:

Hi, Pavel!

Yesterday, I'm started to use your TouchScrolling library, but I still can't understand, how to work with it correctly. Could you help, please?

I have a Sprite in a FlashDevelop project and I want to scroll it.
I use the code:

private var touchScroller:TouchScrollModel;
...
touchScroller = new TouchScrollModel();
touchScroller.setViewportSize(stage.stageWidth, stage.stageHeight);

What should I do next? How to link sprite with touchScroller?

I've also tried to use TouchScroller class as follows:

private var touchScroller:TouchScroller;
...
touchScroller = new TouchScroller();
addChild(touchScroller);

and have few errors:

TouchScrollManager.as(1797): col: 57 Error:
TouchScrollManager.as(1816): col: 40 Error:
TouchScrollManager.as(1857): col: 41 Error:
TouchScrollManager.as(1903): col: 38 Error: Type was not found or was not a compile-time constant: PanGestureEvent.

Please, support me, how can I correctly use your TouchScroller library?

Thanks in advance!


Reply to this email directly or view it on GitHub.

@fljot
Copy link
Owner

fljot commented Oct 24, 2014

@Soniko @fykyx521
guys, the demo is not working anymore. I started to refactor the lib, but it's slightly abandoned now (should work though, can't say if totally stable).

Will speak only for this branch https://github.com/fljot/TouchScrolling/tree/features/decoupled-architecture

So there's this model TouchScrollModel, which does all the calculations based on your input. So you need to configure it:

  1. You need to tell it the min&max scroll position. You can do it via setContentSize and setViewportSize OR by seting scrollBounds excplicitly (if you prefer to calculate it urself, e.g. having negative values).

2, Specify callbacks to be executed when scroll position will be recalculated (during dragging or throw):
positionUpdateCallback
throwCompleteCallback

  1. Configure other behaviours if you like (see public vars).

I'm sorry, but you will need to dig into code a bit as I don't have documentation or examples.

So the first part – configuration – is done.

Now you need to update model when you interact with your interactive object.
Call methods onInteractionBegin (when you touch), onDragBegin (when you drag first time!), onDragUpdate (when you drag), onInteractionEnd. These methods will update model's internal physics and calculated positions will come to positionUpdateCallback and throwCompleteCallback you specified.

This way this model is totally independent from rendering (e.g. you can use it for regular sprites, for flex or custom components, for Stage3D engines – whatever).

@fljot
Copy link
Owner

fljot commented Oct 24, 2014

Feel free to share your progress and help each other. I'm busy, but could help you in case you stuck.

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