Hallo zusammen!
Ich glaube, ich habe gerade einen gewaltigen Hänger (oder meine bescheidenen Mathematik-Kenntnisse reichen hierfür nicht)...
Es geht um folgendes AS:
ActionScript:
_root.createEmptyMovieClip("holder", 1);
for (i=1; i<=20; i++) {
_root.holder.createEmptyMovieClip("mc"+i, i);
_root.holder["mc"+i].createTextField("textfeld", 1, 0, 0, 100, 20);
_root.holder["mc"+i].textfeld.text = i;
_root.holder["mc"+i]._y += total;
total += _root.holder["mc"+i]._height;
}
MovieClip.prototype.dragBar = function() {
startX = 200;
startY = 0;
gesamtHoehe = 200;
gesamtBreite = 20;
scrollerHoehe = Math.ceil(gesamtHoehe*(100*gesamtHoehe/holder._height)/100);
scroller = this.createEmptyMovieClip("scroller", -1);
leiste = this.createEmptyMovieClip("leiste", -2);
with (scroller) {
beginFill(0x000000, 100);
lineStyle(2, 0x000000, 0);
moveTo(startX+2, startY+2);
lineTo(startX+gesamtBreite-2, startY+2);
lineTo(startX+gesamtBreite-2, startY+scrollerHoehe-2);
lineTo(startX+2, startY+scrollerHoehe-2);
lineTo(startX+2, startY+2);
endFill();
}
with (leiste) {
beginFill(0x000000, 50);
lineStyle(2, 0x000000, 100);
moveTo(startX, startY);
lineTo(startX+gesamtBreite, startY);
lineTo(startX+gesamtBreite, startY+gesamtHoehe);
lineTo(startX, startY+gesamtHoehe);
lineTo(startX, startY);
endFill();
}
scroller.onPress = function() {
this.startDrag(false, this._x, 0, this._x, gesamtHoehe-scroller._height);
this.onEnterFrame = function() {
//hier liegt das Problem:
holder._y = Math.ceil((100*(this._y)/(-gesamtHoehe+scroller._height)));
trace(holder._y);
trace(holder._height);
};
};
scroller.onRelease = function() {
this.stopDrag();
delete this.onEnterFrame;
};
};
dragBar();
Ich möchte lediglich, daß sich die Höhe des Scrollbalkens in Relation zum Inhalt anpaßt UND das man noch korrekt scrollen kann.
Das mit der Höhe funktioniert soweit...aber scrollen kann man noch nicht richtig...
Kann mir hier irgendjemand einen kleinen Hinweis geben?
Vielen Dank