moin, moin,
ich will mit folgenden script einen lageplan einzoomen.
PHP-Code:
// Ursprungskoordinatenfunktion
movieclip.prototype.getOrigin = function () {
trace('getOrigin')
this.targetX = this.startX;
this.targetY = this.startY;
this.targetXs = this.startXs;
this.targetYs = this.startYs;
}
// Zielkoordinatenfunktion
movieclip.prototype.getTarget = function (factor) {
trace('getTarget')
this.targetX = this.startX+(this.startX-this._parent._xmouse)*factor;
this.targetY = this.startY+(this.startY-this._parent._ymouse)*factor;
this.targetXs = this.startXs*factor;
this.targetYs = this.startYs*factor;
}
// Zoomfunktion
movieclip.prototype.zoom = function (delay, targetX, targetY) {
trace('zoom')
this.difX = this.targetX-this._x;
difY = this.targetY-this._y;
difXs = this.targetXs-this._xscale;
difYs = this.targetYs-this._yscale;
this._x += (this.difX/delay);
this._y += (difY/delay);
this._xscale += difXs/delay;
this._yscale += difYs/delay;
if(Math.abs(10*this.difX) < 2){
trace('zoomende')
delete this.onEnterFrame
}
}
//
myStadt.startX = myStadt._x;
myStadt.startY = myStadt._y;
myStadt.startXs = myStadt._xscale;
myStadt.startYs = myStadt._yscale;
myStadt.getOrigin();
myStadt.setOnEnterFrame = function(){
this.onEnterFrame = function(){
this.zoom(4, this.targetX,this. targetY);
}
}
myStadt.onMouseDown = function(){
this.getTarget(2)
this.pressed = true;
this.setOnEnterFrame();
}
myStadt.onMouseUp = function(){
this.getOrigin();
this.pressed = false;
this.setOnEnterFrame();
}
myStadt.onMouseMove = function(){
trace('onMouseMove')
if (this.pressed) {
this.getTarget(2);
this.setOnEnterFrame();
}
}
stop ();
soweit funktioniert das auch und sieht klasse aus. ich schaffs allerdings nicht einne grenze zu definieren, über die man die karte nicht hinausschieben kann. bisher kann man den rand der karte in die maske hineinziehen. um das zu vermeiden, habe ich dieses script versucht.
PHP-Code:
// Globale Variablen deklarieren
_global.B = 460;
_global.H = 460;
//Begrenzung
this.onEnterFrame = function() {
//x
if ((this._x+((_parent._xmouse-this._x)/20))>(_global.B-this._width)) {
this._x = (_global.B-this._width);
} else if (this._x<_parent._xmouse && this._x<(_global.B-this._width)) {
this._x += (_parent._xmouse-this._x)/20;
}
if ((this._x-((this._x-_parent._xmouse))/20)<0) {
this._x = 0;
} else if (this._x>_parent._xmouse && this._x>0) {
this._x -= (this._x-_parent._xmouse)/20;
}
//y
if ((this._y+((_parent._ymouse-this._y)/20))>(_global.B-this._width)) {
this._y = (_global.B-this._width);
} else if (this._y<_parent._ymouse && this._y<(_global.B-this._width)) {
this._y += (_parent._ymouse-this._y)/20;
}
if ((this._y-((this._y-_parent._ymouse))/20)<0) {
this._y = 0;
} else if (this._y>_parent._ymouse && this._y>0) {
this._y -= (this._y-_parent._ymouse)/20;
}
};
das hab ich direkt auf den mc mit der karte gelegt, damit allerdings nur erreicht, dass gar nix mehr funktioniert.. kann mir damit jemand weiterhelfen? oder eine andere möglichkeit aufzeigen die begrenzung zu definieren?
wär eine spitzensache! danke schon mal!