View Full Version : Problem with scrolling text box... PLEASE HELP!
tkbstudd
05-13-2008, 06:32 PM
I'm trying to create a dynamic text box that scrolls. When I paste the text I want the text box resized and I can't size it back down to fit in the window I created. What am I doing wrong?
mitzs
05-14-2008, 06:07 PM
I found this.
myTextbox.autoSize = true;
http://www.kirupa.com/forum/showthread.php?t=71883
snickelfritz
05-15-2008, 03:49 AM
Here's an actionscript 3.0 that links your dynamic textfield to a plain text file on the server. (in this example, "pharetra.txt")
It also allows you to easily create your own custom scrollbar graphics.
Scrolling is super-smooth and has adjustable easing.
This is based on the scrollbar tutorial from gotoandlearn.com (http://www.gotoandlearn.com/index.php?as=3)
TweenMax (http://blog.greensock.com/tweenmaxas3/) is required for the example posted here (http://www.byrographics.com/AS3/textScroller/scrollingText.html).
import gs.TweenMax;
import fl.motion.easing.*;
stage.scaleMode = StageScaleMode.NO_SCALE;
function loadText():void {
var txtLoader:URLLoader = new URLLoader();
txtLoader.addEventListener(Event.COMPLETE, onLoaded);
content.autoSize = TextFieldAutoSize.LEFT;
txtLoader.load(new URLRequest("pharetra.txt"));
removeEventListener(Event.COMPLETE, onLoaded);
function onLoaded(e:Event):void {
content.text = txtLoader.data;
}
}
loadText();
var yOffset:Number;
var yMin:Number = 0;
var yMax:Number = sb.track.height - sb.thumb.height;
sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);
function thumbDown(e:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
yOffset = mouseY - sb.thumb.y;
}
function thumbUp(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}
function thumbMove(e:MouseEvent):void {
sb.thumb.y = mouseY - yOffset;
if (sb.thumb.y <= yMin) {
sb.thumb.y = yMin;
}
if (sb.thumb.y >= yMax) {
sb.thumb.y = yMax;
}
var sp:Number = sb.thumb.y / yMax;
TweenMax.to(content, 1, {y:(-sp*(content.height - masker.height)), ease:Back.easeOut});
e.updateAfterEvent();
}
vBulletin® v3.7.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.