由于带滚动条的动态文本框无法竖着显示文字,于是通过把竖着显示得静态文本框转换成元件,遮罩层盖在内容层上,实现拉滚动条,元件左右移动,在遮罩层的帮助下,实现竖排文字左右移动的效果,然后通过代码加入移动的缓冲效果,注意最后一帧的代码是跳转到前一帧,通过循环才能实现移动缓冲的效果,而不是在同一帧内实现。。。
<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;
}
}
}
点此立即下载实例源码
990

被折叠的 条评论
为什么被折叠?



