APB
%Europe/Berlin %409 %2005, 10:49
Ik wil nu met mijn eend scrollbar... een tekst laten scrollen... ik knal er een mask overheen dus de grootte van het tekstveld maakt niet uit... maar nu komt het, ik wil dat als het veld op bijvoorbeeld "_y = 100" komt dat hij dan niet meer verder scrollt of iets in die richting...
mijn frame actions:
myLV = new LoadVars();
myLV.load("data.txt");
myLV.onLoad = function(success) {
if (success) {
//trace(this.inhoud);
tekstVakje.text = this.inhoud;
//inhoud is de naam van de variable in het textbestandje
}
};
if (_root.tekstVakje._y == 100) { //om dit gedeelte gaat het dus
scrollingDown = "no";
} else if (_root.tekstVakje._y == 0) {
scrollingUp = "no";
} else {
scrollingUp = "yes";
scrollingDown = "yes"
}
trace(tekstVakje._y);
trace(scrollingUp);// hij geeft hier wel keurig "yes" aan.
trace(scrollingDown)// hij geeft hier wel keurig "yes" aan.
actions in de scroll eend.
onClipEvent (load) {
this.speed = 70;
// create an array of all MC positions along the tween
this.generatePosArray = function() {
this.pos = new Array();
var curr = this._currentframe;
var L = this._totalFrames;
for (var i = 0; i<L; i++) {
this.gotoAndStop(i+1);
this.pos[i] = {x:this.dragClip._x, y:this.dragClip._y};
}
this.gotoAndStop(curr);
};
// calculate the square of distance from MC to mouse
// (quicker not to take square root)
this.getMouseDist2 = function(position, mousePos) {
var dx = position.x-mousePos.x;
var dy = position.y-mousePos.y;
return dx*dx+dy*dy;
};
// calculate frame in the given range in which
// the MC is closest to the mouse
nearestFrame = function (mousePos) {
// get local references for extra speed
var currFrame = this._currentframe;
var pos = this.pos;
// find out which direction along the curve takes the MC closer to the mouse position
if (this.getMouseDist2(pos[currFrame+1], mousePos)<this.getMouseDist2(pos[currFrame], mousePos)) {
var dir = 1;
// forwards
if(scrollingUp = "yes"){ //ook om dit gedeelte gaat het
_root.tekstVakje._y -= 10;
}
} else if (this.getMouseDist2(pos[currFrame-1], mousePos)<this.getMouseDist2(pos[currFrame], mousePos)) {
var dir = -1;
// backwards
if(scrollingDown = "yes"){ //ook om dit gedeelte gaat het
_root.tekstVakje._y += 10;
}
} else {
return currFrame;
// stay in the same position
}
var lastFrame = currFrame+this.speed*dir;
for (var frame = currFrame; frame != lastFrame; frame += dir) {
if (this.getMouseDist2(pos[frame], mousePos)<this.getMouseDist2(pos[frame+dir], mousePos)) {
return frame;
// return minimum
}
}
// didn't find a minimum, so return closest within the speed limit
return frame;
};
// set position of MC to nearest to mouse
this.setNewPos = function() {
if (this.dragClip.drag) {
var mousePos = {x:this._xmouse, y:this._ymouse};
gotoAndStop(this.nearestFrame(mousePos));
}
};
// calculate all positions of MC before we start
this.generatePosArray();
}
onClipEvent (enterFrame) {
this.setNewPos();
}
mijn frame actions:
myLV = new LoadVars();
myLV.load("data.txt");
myLV.onLoad = function(success) {
if (success) {
//trace(this.inhoud);
tekstVakje.text = this.inhoud;
//inhoud is de naam van de variable in het textbestandje
}
};
if (_root.tekstVakje._y == 100) { //om dit gedeelte gaat het dus
scrollingDown = "no";
} else if (_root.tekstVakje._y == 0) {
scrollingUp = "no";
} else {
scrollingUp = "yes";
scrollingDown = "yes"
}
trace(tekstVakje._y);
trace(scrollingUp);// hij geeft hier wel keurig "yes" aan.
trace(scrollingDown)// hij geeft hier wel keurig "yes" aan.
actions in de scroll eend.
onClipEvent (load) {
this.speed = 70;
// create an array of all MC positions along the tween
this.generatePosArray = function() {
this.pos = new Array();
var curr = this._currentframe;
var L = this._totalFrames;
for (var i = 0; i<L; i++) {
this.gotoAndStop(i+1);
this.pos[i] = {x:this.dragClip._x, y:this.dragClip._y};
}
this.gotoAndStop(curr);
};
// calculate the square of distance from MC to mouse
// (quicker not to take square root)
this.getMouseDist2 = function(position, mousePos) {
var dx = position.x-mousePos.x;
var dy = position.y-mousePos.y;
return dx*dx+dy*dy;
};
// calculate frame in the given range in which
// the MC is closest to the mouse
nearestFrame = function (mousePos) {
// get local references for extra speed
var currFrame = this._currentframe;
var pos = this.pos;
// find out which direction along the curve takes the MC closer to the mouse position
if (this.getMouseDist2(pos[currFrame+1], mousePos)<this.getMouseDist2(pos[currFrame], mousePos)) {
var dir = 1;
// forwards
if(scrollingUp = "yes"){ //ook om dit gedeelte gaat het
_root.tekstVakje._y -= 10;
}
} else if (this.getMouseDist2(pos[currFrame-1], mousePos)<this.getMouseDist2(pos[currFrame], mousePos)) {
var dir = -1;
// backwards
if(scrollingDown = "yes"){ //ook om dit gedeelte gaat het
_root.tekstVakje._y += 10;
}
} else {
return currFrame;
// stay in the same position
}
var lastFrame = currFrame+this.speed*dir;
for (var frame = currFrame; frame != lastFrame; frame += dir) {
if (this.getMouseDist2(pos[frame], mousePos)<this.getMouseDist2(pos[frame+dir], mousePos)) {
return frame;
// return minimum
}
}
// didn't find a minimum, so return closest within the speed limit
return frame;
};
// set position of MC to nearest to mouse
this.setNewPos = function() {
if (this.dragClip.drag) {
var mousePos = {x:this._xmouse, y:this._ymouse};
gotoAndStop(this.nearestFrame(mousePos));
}
};
// calculate all positions of MC before we start
this.generatePosArray();
}
onClipEvent (enterFrame) {
this.setNewPos();
}