Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 10-03-2004, 15:40   #1 (permalink)
Neuer User
 
Registriert seit: Nov 2003
Ort: Köln, Freiburg
Beiträge: 22
Question Scrollbalken anpassen

hallo zusammen,

ich habe eine textbox, die den text extern einläd.
da der text austauschabr ist, wird auch die textbox je nach inhalt unterschiedlich groß. nun soll sich der balken natürlich der box anpassen. ich habe bereits einen, der nur dies allerdings nicht tut.
wenn das hilft, poste ich hier mal das as rein, was dahinter liegt.

es dankt nochmal: candida


onClipEvent (load) {
// ---------------------------------------------------------------------------------------
// --initialze variables
numLines = 20;
// guesstimate of number of visible lines in text area
tolerance = 1;
// controls how close the scroll bar can get before snapping to target
speed = 5;
// controls re-size and re-position animation speed
origHeight = scrollbar._height;
origX = (scrollbar._x+1);
text = "";
// ---------------------------------------------------------------------------------------
// --resizes scrollbar according to content length
function scrollResize() {
lastHeight = scrollbar._yscale;
totalLines = (text.maxscroll-1)+numLines;
newHeight = 100*(numLines)/totalLines;
scaleDiff = Math.abs(newHeight-lastHeight);
currentPosition = scrollbar._y;
pixelDiff = currentPosition-(arrowUp._height-1);
}
// ---------------------------------------------------------------------------------------
// --positions scrollbar when text is scrolled
function scrollPosition() {
scrollbar._y = (lineHeight*(text.scroll-1))+(arrowUp._height-1);
}
}
// -------------------------------------------------------------------------------------------
onClipEvent (enterFrame) {
scrollResize();
// ---------------------------------------------------------------------------------------
// --animate the scale and position of scrollbar if resize is required
if (lastHeight<>newHeight) {
if (scaleDiff<tolerance && scaleDiff>(0-tolerance)) {
scrollbar._yscale = newHeight;
heightDiff = origHeight-scrollbar._height;
lineHeight = HeightDiff/(text.maxscroll-1);
rePosition = false;
text.scroll = 1;
scrollPosition();
} else {
if (newHeight<lastHeight) {
scrollbar._yscale = scrollbar._yscale-(scaleDiff/speed);
} else if (newHeight>lastHeight) {
scrollbar._yscale = scrollbar._yscale+(scaleDiff/speed);
}
}
}
if (rePosition == true) {
currentPosition = currentPosition-(pixelDiff/speed);
scrollbar._y = currentPosition;
pixelDiff = pixelDiff-(pixelDiff/speed);
if (currentPosition == (arrowUp._height-1)) {
rePosition = false;
}
}
// ---------------------------------------------------------------------------------------
// --scrolling when arrows are pressed
if (startScroll == true) {
if (scroll == "up" && text.scroll>1) {
text.scroll--;
scrollPosition();
}
if (scroll == "down" && text.scroll<text.maxscroll) {
text.scroll++;
scrollPosition();
}
}
// ---------------------------------------------------------------------------------------
// --page text if mouse is clicked within the scrollarea
if (paging == true) {
if (hitLocation<scrollbar._y) {
text.scroll -= numLines;
scrollPosition();
if (hitLocation>=scrollbar._y && hitLocation<=(scrollbar._y+scrollbar._height)) {
paging = false;
}
} else {
text.scroll += numLines;
scrollPosition();
if (hitLocation>=scrollbar._y && hitLocation<=(scrollbar._y+scrollbar._height)) {
paging = false;
}
}
}
// test = (arrowDown._y - arrownDown._height) - scrollbar._height;
}
// --------------------------------------------------------------------------------------------
onClipEvent (mouseDown) {
// --detect if mouse click is in scrollarea but not on scrollbar
if (scrollArea.hitTest(_root._xmouse, _root._ymouse) and not scrollbar.hitTest(_root._xmouse, _root._ymouse)) {
hitLocation = this._ymouse;
paging = true;
resize = false;
}
// --detect if mouse click is on up arrow button
if (arrowUp.hitTest(_root._xmouse, _root._ymouse)) {
scroll = "up";
startScroll = true;
arrowUp.gotoAndPlay(2);
resize = false;
}
// --detect if mouse click is on down arrow button
if (arrowDown.hitTest(_root._xmouse, _root._ymouse)) {
scroll = "down";
startScroll = true;
arrowDown.gotoAndPlay(2);
resize = false;
}
// --detect if mouse click is on scrollbar
if (scrollbar.hitTest(_root._xmouse, _root._ymouse)) {
startDrag(scrollbar, false, origX, arrowUp._height-1, origX, heightDiff+(arrowUp._height-1));
scroll = "scrollbar";
scrollbar.gotoAndPlay(2);
resize = false;
}
}
// --------------------------------------------------------------------------------------------
// --reset scroll properties when mouse button is released
onClipEvent (mouseUp) {
scroll = "";
startScroll = false;
paging = false;
stopDrag();
resize = true;
scrollbar.gotoAndStop(1);
arrowUp.gotoAndStop(1);
arrowDown.gotoAndStop(1);
}
// --------------------------------------------------------------------------------------------
// -adjust text when scroll bar is dragged
onClipEvent (mouseMove) {
if (scroll == "scrollbar") {
text.scroll = Math.round((scrollbar._y-arrowUp._height)/lineHeight+1);
// --test for scrollbar position to correct errors created by numLines guesstimate
if (scrollbar._y == Math.ceil(arrowDown._y-(arrowDown._height-1)-scrollbar._height)) {
text.scroll = text.maxscroll;
}
}
updateAfterEvent();
}
// --------------------------------------------------------------------------------------------
// --detects when content is text box is changed...reset scroll property and resize scroll bar
onClipEvent (data) {
rePosition = true;
scrollResize();
text.scroll = 1;
}
candida ist offline   Mit Zitat antworten
Alt 10-03-2004, 15:44   #2 (permalink)
42!
 
Benutzerbild von nemaxtowni
 
Registriert seit: Nov 2003
Beiträge: 538
hey wenn du lust hast kannst du mir mal die fla datei schicken...ich versuch so etwas auch gerade und schaff es einfach nicht...bin nichmtla so weit gekommen wie du...wäre suppa wenn du mir die fla datei mal zuschicken könntest

info@johz-design.de
nemaxtowni ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 05:29 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele