如何在 AIR-Android 中上下移动内容?
我正在使用 Flash CS 5 和 Flex 4,两者都是为 Android 构建 AIR 应用程序。我想知道如何允许用户上下移动内容(图像或文本)(如地图,在本例中仅垂直移动)。
I'm using Flash CS 5 and Flex 4, both to build an AIR application for android. I would like to know how to allow the user to move content(image or text) up and down(like a map,in this case only vertically).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前还没有可用的触摸 UI 控件,因此您需要自己实现。这里有一些代码可能会帮助您入门。我把它写在时间线上,以便我可以快速测试。如果您在课堂上使用它,则需要进行一些调整。
变量
content
是舞台上的MovieClip。如果它大于舞台的高度,您可以通过用鼠标拖动(或用手指在触摸屏上)来滚动它。如果它小于舞台的高度,那么它根本不会滚动,因为它不需要。或者,您可以使用
scrollRect
属性。这个非常好,因为它将为您将内容屏蔽到一个矩形区域。如果您只是像上面的代码一样更改y
,您可以在滚动内容的顶部绘制其他显示对象来模拟遮罩。它也比scrollRect
更快。There are no touch UI controls available yet, so you need to implement it yourself. Here's a little bit of code that might help get you started. I wrote it on the timeline so that I could test it quickly. You'll need to make a couple adjustments if you're using it in a class.
The variable
content
is a MovieClip that is on the stage. If it is larger than the height of the stage, you'll be able to scroll it by dragging it with the mouse (or with your finger on a touch screen). If it is smaller than the height of the stage, then it won't scroll at all because it doesn't need to.Alternatively, you could use the
scrollRect
property. That one is pretty nice because it will mask the content to a rectangular region for you. If you just changey
like in the code above, you can draw other display objects on top of the scrolling content to simulate masking. It's faster thanscrollRect
too.