as3滚动条控制元件移动 带缓冲效果
来源:互联网 发布:有没有免费的域名 编辑:程序博客网 时间:2024/06/05 05:23
由于带滚动条的动态文本框无法竖着显示文字,于是通过把竖着显示得静态文本框转换成元件,遮罩层盖在内容层上,实现拉滚动条,元件左右移动,在遮罩层的帮助下,实现竖排文字左右移动的效果,然后通过代码加入移动的缓冲效果,注意最后一帧的代码是跳转到前一帧,通过循环才能实现移动缓冲的效果,而不是在同一帧内实现。。。
<code>drag.addEventListener(MouseEvent.MOUSE_DOWN,dragMouseDown);
stage.addEventListener(MouseEvent.MOUSE_WHEEL,scrolldrag);
stage.addEventListener(Event.ENTER_FRAME,scrollText);
drag.buttonMode = true;</code>
function dragMouseDown(evt:MouseEvent):void
{
drag.startDrag(false,new Rectangle(dx,dy,0,bar.height - drag.height));
stage.addEventListener(MouseEvent.MOUSE_UP,dragMouseUp);
addEventListener(Event.ENTER_FRAME,scrollText);
}
function dragMouseUp(evt:MouseEvent):void
{
drag.stopDrag();
//stage.removeEventListener(MouseEvent.MOUSE_UP,dragMouseUp);
//removeEventListener(Event.ENTER_FRAME,scrollText);
}
function scrollText(evt:Event):void
{
var percentScrolled:Number = (drag.y - dy) / 239;
var moveto:Number = infox + percentScrolled * 423;
if(moveto > info_text.x)
{
info_text.x += (moveto - info_text.x)*0.1;
if(Math.abs(moveto - info_text.x) {
info_text.x = moveto;
}
}
if(moveto < info_text.x)
{
info_text.x -= (info_text.x - moveto)*0.1;
if(Math.abs(info_text.x - moveto) {
info_text.x = moveto;
}
}
}
function scrolldrag(evt:MouseEvent):void
{
var percentScrolled:Number = 0;
var moveto:Number = 0;
if(evt.delta < 0 && drag.y < dy + 239 ) {
drag.y = drag.y + 10;
percentScrolled = (drag.y - dy) / 239;
moveto = infox + percentScrolled * 423;
info_text.x += (moveto - info_text.x)*0.1;
if(Math.abs(moveto - info_text.x) {
info_text.x = moveto;
}
}
if(evt.delta > 0 && drag.y > dy ) {
drag.y = drag.y - 10;
percentScrolled = (drag.y - dy) / 239;
moveto = infox + percentScrolled * 423;
info_text.x -= (info_text.x - moveto)*0.1;
if(Math.abs(info_text.x - moveto) {
info_text.x = moveto;
}
}
}
点此立即下载实例源码
<code>drag.addEventListener(MouseEvent.MOUSE_DOWN,dragMouseDown);
stage.addEventListener(MouseEvent.MOUSE_WHEEL,scrolldrag);
stage.addEventListener(Event.ENTER_FRAME,scrollText);
drag.buttonMode = true;</code>
function dragMouseDown(evt:MouseEvent):void
{
drag.startDrag(false,new Rectangle(dx,dy,0,bar.height - drag.height));
stage.addEventListener(MouseEvent.MOUSE_UP,dragMouseUp);
addEventListener(Event.ENTER_FRAME,scrollText);
}
function dragMouseUp(evt:MouseEvent):void
{
drag.stopDrag();
//stage.removeEventListener(MouseEvent.MOUSE_UP,dragMouseUp);
//removeEventListener(Event.ENTER_FRAME,scrollText);
}
function scrollText(evt:Event):void
{
var percentScrolled:Number = (drag.y - dy) / 239;
var moveto:Number = infox + percentScrolled * 423;
if(moveto > info_text.x)
{
info_text.x += (moveto - info_text.x)*0.1;
if(Math.abs(moveto - info_text.x) {
info_text.x = moveto;
}
}
if(moveto < info_text.x)
{
info_text.x -= (info_text.x - moveto)*0.1;
if(Math.abs(info_text.x - moveto) {
info_text.x = moveto;
}
}
}
function scrolldrag(evt:MouseEvent):void
{
var percentScrolled:Number = 0;
var moveto:Number = 0;
if(evt.delta < 0 && drag.y < dy + 239 ) {
drag.y = drag.y + 10;
percentScrolled = (drag.y - dy) / 239;
moveto = infox + percentScrolled * 423;
info_text.x += (moveto - info_text.x)*0.1;
if(Math.abs(moveto - info_text.x) {
info_text.x = moveto;
}
}
if(evt.delta > 0 && drag.y > dy ) {
drag.y = drag.y - 10;
percentScrolled = (drag.y - dy) / 239;
moveto = infox + percentScrolled * 423;
info_text.x -= (info_text.x - moveto)*0.1;
if(Math.abs(info_text.x - moveto) {
info_text.x = moveto;
}
}
}
点此立即下载实例源码
0 0
- as3滚动条控制元件移动 带缓冲效果
- 移动效果(面向滚动条)
- 内嵌DIV带滚动条效果
- JQ带滚动效果的导航条
- as3 水平滚动条
- as3滚动条设计
- 带效果的移动导航条
- JS带缓冲效果打开、关闭、移动一个层
- 文本框滚动缓冲效果
- js小技巧8 带纹理网页滚动条效果
- js 实现层随滚动条移动效果
- js 实现层随滚动条移动效果
- div带滚动条
- 带滚动条TextView
- QmlTextEdit带滚动条
- Div滚动条移动
- 滚动条效果实现
- 滚动加载条效果
- linux-2.6.20内核移植 busybox1.9.2 并移植USB驱动
- wamp修改mysql密码
- php file_get_content(URL) 执行URL,获取返回结果集
- 编码详解(上)
- mysql报错不是英文
- as3滚动条控制元件移动 带缓冲效果
- 求子数组的最大和 【微软面试100题 第三题】
- iOS-浅谈runtime运行时机制02
- 关于未能向文件“obj\Debug\ContactUI.csproj.FileListAbsolute.txt”写入命令行。
- 编码详解(下)
- PHP使用iconv函数遍历数组转换字符集
- IOS中info.plist文件的关键字描述
- iOS中堆和栈的区别
- OpenStack J版 Neutron-server服务加载与启动源码分析(一)