ActionScript:手动滚动滚动窗口内的元素
我的问题的答案可能很简单,但我还没有在网络中找到解决该问题的示例,也没有找到阅读 ActionScript 参考的解决方案。
我的问题如下:我在 Scroller (spark.components.Scroller) 窗口内有一个很大的 UIComponent 派生元素。 Scroller 类很棒,因为当动态更改大小的画布元素超出其边界时,滚动条会自动出现并处理其中的 UIComponent 的滚动。
然而,我不仅希望能够使用这些自动出现的滚动条进行滚动,还希望能够使用我自己实现的平移工具(例如,类似于 Adobe 软件中的手动工具)。问题是我无法正确修改滚动窗口内元素的位置。
作为第一种方法,我尝试访问元素的“x”和“y”属性,但是,在更改它们时,我没有得到想要的结果。它的代码如下(其中,出于简化原因,我使用文本标签作为“内部”元素,并使用两个按钮作为外部滚动控制器,而不是手动工具)
测试。 mxml
<fx:Script>
<![CDATA[
protected function der_clickHandler(event:MouseEvent):void
{
text.x += 5;
}
protected function izq_clickHandler(event:MouseEvent):void
{
text.x -= 5;
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<s:Scroller id="sc" x="50" y="50" width="200" height="100">
<s:Group width="100%" height="100%">
<s:Label id="text" width="400" height="10" x="50" y="50" text="blebleblebleblebleblebleblebleblebleblebleble"/>
</s:Group>
</s:Scroller>
<s:Button id="der" x="154" y="182" label="->" click="der_clickHandler(event)"/>
<s:Button id="izq" x="76" y="182" label="<-" click="izq_clickHandler(event)"/>
</s:Application>
还有一个编译版本的链接,看看我在说什么: http://megaswf.com/file/1135821 (如果您看不到它,请按“全屏查看”)
非常感谢您的帮助,因为我整个下午都被困在这个问题上,并且我的项目确实需要它:S
无论如何,提前非常感谢,并致以问候!
The answer to my question is possibly easy, yet I haven't found an example of solving it in the web, nor have I found a solution reading ActionScript reference.
My problem is the following: I have a big UIComponent derivate element inside a Scroller (spark.components.Scroller) window. The Scroller class is great because when my canvas element, that changes size dynamically, exceeds its boundaries, scrollbars appear automatically and handle scrolling of my UIComponent inside it.
However, I'd like not just to be able to Scroll using these automatically appeared scroll bars, but also by using a pan tool that I will myself implement (similar to the hand tool in Adobe software, for example). The thing is that I am not able to modify correctly the element's position inside the Scroller window.
I tried, as a first approach, accessing to my elements' 'x' and 'y' properties, however, when changing them, I dont get the resulkts wanted. The code for it is the following (in which, for symplifying reasons, I used a text label as my 'inside' element, and two buttons as an external scroll controller, instead of a hand tool)
Tests.mxml
<fx:Script>
<![CDATA[
protected function der_clickHandler(event:MouseEvent):void
{
text.x += 5;
}
protected function izq_clickHandler(event:MouseEvent):void
{
text.x -= 5;
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<s:Scroller id="sc" x="50" y="50" width="200" height="100">
<s:Group width="100%" height="100%">
<s:Label id="text" width="400" height="10" x="50" y="50" text="blebleblebleblebleblebleblebleblebleblebleble"/>
</s:Group>
</s:Scroller>
<s:Button id="der" x="154" y="182" label="->" click="der_clickHandler(event)"/>
<s:Button id="izq" x="76" y="182" label="<-" click="izq_clickHandler(event)"/>
</s:Application>
And a link to a compiled version, to see what I'm speaking about:
http://megaswf.com/file/1135821
(press 'view fullscreen' if you can't see it)
Help would be really appreciated, as I've been stuck all afternoon with this, and really need it for my project :S
Anyway, many thanks in advance, and regards!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我设法解决了它! (这是我本周第二次在将问题发布到此处后解决问题:D)。
我必须更改的属性是 sc.viewport.horizontalScrollPosition+=5;而不是内部元素的“x”位置。垂直位置也是如此。
I managed to solve it! (This is the second time this week that I solve something just after posting it here :D).
The property that I had to change is sc.viewport.horizontalScrollPosition+=5; instead of the internal elements 'x' position. And the same for vertical pos.