as3使用scrollRect来实现内容滚动
2012-10-17 11:51
357 查看
以前一直用sprite套sprite实现滚动......今天发一个清爽一点的....
package { import flash.display.Sprite; import flash.geom.Rectangle; import flash.events.MouseEvent; import flash.events.Event; public class SampleScrollRect extends Sprite { private var circle : Sprite; private var slider : Sprite; public function SampleScrollRect() { circle = new Sprite(); circle.graphics.beginFill(0xFFCC00); circle.graphics.drawCircle(200, 200, 200); circle.scrollRect = new Rectangle(0, 0, 200, 200); addChild(circle); slider = new Sprite(); slider.graphics.beginFill(0xff0000); slider.graphics.drawRect(0, 0, 10, 30); slider.graphics.endFill(); addChild(slider); slider.x = 300; slider.addEventListener(MouseEvent.MOUSE_DOWN, _down); slider.addEventListener(MouseEvent.MOUSE_UP, _up); } private function _down(e : MouseEvent) : void { stage.addEventListener(MouseEvent.MOUSE_MOVE, _move); stage.addEventListener(MouseEvent.MOUSE_UP, _up); } private function _up(e : MouseEvent) : void { stage.removeEventListener(MouseEvent.MOUSE_MOVE, _move); stage.removeEventListener(MouseEvent.MOUSE_UP, _up); } private function _move(event : MouseEvent) : void { var rect : Rectangle = circle.scrollRect; trace(mouseY); rect.y = mouseY; slider.y = mouseY; trace(rect); circle.scrollRect = rect; } } }
相关文章推荐
- Unity3D ScrollRect+ContentSizeFitter+GridLayoutGroup实现无限滚动之排行榜(二)
- 微信小程序例子——如何使用scroll-view组件实现视图垂直滚动
- 使用css实现页面头部固定,下面随着内容的增多滚动,但是头部不动的效果
- iPhone开发之UIScrollView滚动组件的使用(三) 拖线实现按钮控制大图移动之contentInsets增加内容边距
- 初识UGUI之Scroll Rect,实现滚动效果
- Wpf ScrollViewer with WrapPanel 使用鼠标滚轮水平滚动内容
- 使用vue-infinite-scroll实现无限滚动效果
- vue使用Better-Scroll实现纵向滚动
- iOS - 支持水平 / 垂直显示自动滚动的跑马灯控件 --- SKAutoScrollLabel 的使用和实现
- Unity3D ScrollRect+ContentSizeFitter+GridLayoutGroup实现无限滚动(一)
- 10.15 周日 阵雨 早起 关于物品栏的翻页及Toggle Group组件 Mask遮挡模型 Scroll rect 滚动列表的熟悉和使用
- android 使用HorizontalScrollView 实现标题带动内容左右切屏
- 使用UGUI ScrollView 排列不规则内容元素实现滑动效果
- 使用idangerous.swiper.min.js和iscroll5.js实现横向滚动tab,并响应内容
- javascript实现图片无缝滚动(scrollLeft的使用方法介绍)
- UGUI 使用ScrollRect实现地图拖放及多点缩放
- 使用 HorizontalScrollView 实现水平滚动,并点击有相应的反应效果
- 使用ScrollView实现滚动效果 出现 ScrollView can host only one direct child (ScrollView只能包裹一个直接子元素)
- As3显示对象scrollRect滚动问题
- 使用 HorizontalScrollView 实现滚动控制