开发者

AS3 calculating ScrollPane.verticalScrollPosition

开发者 https://www.devze.com 2023-02-06 03:21 出处:网络
I spend almost 3 hours trying to figure this out, hope someone can help me. I have a a set up like this:

I spend almost 3 hours trying to figure this out, hope someone can help me.

I have a a set up like this:

ScrollPane > Sprite > multiple Loader one after another along y coordinate > external swf.

  • The setup is to allow scrolling of the loader/swf vertically.
  • All the objects have unit scale (no scale) except for Sprite which may have a scale factor due to zoom.
  • The external swf are pages from a PDF, one page per swf.

All is good so far.

Now, I have a set of next and back navigation button to step through the pages. The problem is I cannot find the correct formula to calculate the ScrollPane.verticalScrollPosition to set to.

Can you spot the mistake here? Thanks..开发者_如何学编程.

scroll_per_height = scrollpane.maxVerticalScrollPosition / (sprite.height - scrollpane.height);
height_per_page = sprite.height / sprite.loaders.Count
scroll_position = (page - 1) * height_per_page  * scroll_per_height;


Usually I just delete my question if i find out the answer before anyone replies. But I think this will help some people at least:

The verticalScrollPosition is not the scrollbar's scroller position, instead, it's actually the y-coordinate offset of the scrollpane.content

0

精彩评论

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