Hi,
habe es leider nicht hinbekommen. Nachdem ich das Zeitleistenscript in eine Klasse kopiert habe kommen noch einige Fehlermeldungen. Manche "statements" sind wieder nicht zugelassen. Ich weiß aber nicht, wie man es umschreibt. Unterhalb ist der original Code von der Zeitleiste.
Ich habe die Fehlermeldungen in die jeweilige Zeile geschrieben. Ich hoffe, ihr kommt damit zurecht. Heut Abend kann ich die Datei noch uploaden. Geht an der FH leider nicht.
Sinn der Klasse soll das Zoomen in eine Karte sein. Diese kann man per Drag&Drop in der Maske hin- und herschieben.
LG Karl
PHP-Code:
class core.Navigation extends MovieClip
{
//Karte + Maske
Karte_mc.setMask(Maske_mc); //This statement is not permitted in a class defintion.
var minZoom:Number = 1; // 1 ist so, dass man alles sieht
var maxZoom:Number = 15; // 1 ist so, dass man alles sieht
var zoomSpeed:Number = 0.05;
var z:Number = 1; // 1 ist so, dass man alles sieht
var x:Number = .5; // 0 ist links - 1 ist rechts
var y:Number = .5; // 0 ist oben - 1 ist unten
var contSkal:Number = _.root.Karte_mc._width / _root.Karte_mc._height;
var maskSkal:Number = _root.Maske_mc._width / _root.Maske_mc._height;
var showAllWidth:Number = contSkal > maskSkal ? _root.mask._width : _root.Maske_mc._height * contSkal; //Maske_mc wird erst unten erstellt?
var showAllHeight:Number = showAllWidth / contSkal;
public function Navigation()
{
var map_mc:MovieClip;
map_mc = _root;
map_mc.attachMovie("Karte", "Karte_mc", 9); //Welche Tiefe ist am besten?
map_mc.Karte.mc._x = 6.2;
map_mc.Karte_mc._y = 75;
map_mc.Karte_mc._width = 464.7;
map_mc.Karte_mc._height = 581.9;
var zoom_mc:MovieClip;
zoom_mc = _root;
zoom_mc.attachMovie("Regler", "Regler_mc", 9); //Welche Tiefe ist am besten?
zoom_mc.Regler_mc._x = 437;
zoom_mc.Regler_mc._y = 192;
var mask_mc:MovieClip;
mask_mc = _root;
mask_mc.attachMovie("Maske", "Maske_mc", 9); //Welche Tiefe ist am besten?
mask_mc.Regler_mc._x = 10;
mask_mc.Regler_mc._y = 63;
mask_mc.Regler_mc._width = 460;
mask_mc.Regler_mc._height = 575;
}
//Muss ich jedesmal _root davorschreiben?
function updateZoom() {
_root.Karte_mc._width = showAllWidth * z;
_root.Karte_mc._height = showAllHeight * z;
}
function updatePosition() {
_root.Karte_mc._x = Math.floor(_root.Maske_mc._x + (_root.Maske_mc._width - _root.container._width) * x);
_root.Karte_mc._y = Math.floor(_root.Maske_mc._y + (_root.Maske_mc._height - _root.container._height) * y);
}
function updateSlider() {
var rel:Number = (z - minZoom) / (maxZoom - minZoom);
_root.Regler.dragger._y = _root.Regler.track._y + (_root.Regler.track._height - _root.Regler.dragger._height) * rel;
}
//This statement is not permitted in a class definition. (Alle 3)
updateZoom();
updatePosition();
updateSlider();
// Dragging
//Hier wird die Karte von oben verwendet. Besser in eine eigene Klasse schreiben?
private function onPress()
{
_root.karte_mc.startDrag(false,
_root.Maske_mc._x + _root.Maske_mc._width - _root.Karte_mc._width,
_root.Maske_mc._y + _root.Maske_mc._height - _root.Karte_mc._height,
_root.Maske_mc._x,
_root.Maske_mc._y)
private function onMouseMove() //Attribute used outside class
{
if (Math.abs(_root.Karte_mc._width - _root.Maske_mc._width) > 3)
{
x = (_root.Karte_mc._x - Maske_mc._x) / (_root.Maske_mc._width - _root.Karte_mc._width);
x = Math.max(0, Math.min(1, x));
}
if (Math.abs(_root.Karte_mc._height - _root.Maske_mc._height) > 3)
{
y = (_root.Karte_mc._y - mask._y) / (_root.Maske_mc._height - _root.Karte_mc._height);
y = Math.max(0, Math.min(1, y));
}
}
}
// Wie mach ich daraus eine "Klassenfunktion"?
//This statement is not permitted in a class defintion.
_root.karte_mc.onRelease = _root.Karte_mc.onReleaseOutside = function() {
stopDrag();
delete this.onMouseMove;
}
// Regler
private function onPress() //The same member name may not be repeated more than once.
{
_root.startDrag(false, this._x, this._parent.track._y, this._x, this._parent.track._y + this._parent.track._height - this._height);
private function onMouseMove() //Attribute used outsid class.
{
var rel:Number = (_root.Regler_mc.dragger._y - _root.Regler_mc.track._y) / (_root.Regler_mc.track._height - _root.Regler_mc.dragger._height);
z = minZoom + rel * (maxZoom - minZoom);
updateZoom();
updatePosition();
}
}
// Wie mach ich daraus eine "Klassenfunktion"?
//This statement is not permitted in a class defintion.
_root.Regler_mc.dragger.onRelease = _root.Regler_mc.dragger.onReleaseOutside = function () {
stopDrag();
delete this.onMouseMove;
}
}
/////// Ursprünglicher Code der Zeitleiste /////////
// Karte noch als Container bezeichnet!
/**
//Karte + Maske
container.setMask(mask);
var minZoom:Number = 1; // 1 ist so, dass man alles sieht
var maxZoom:Number = 15; // 1 ist so, dass man alles sieht
var zoomSpeed:Number = 0.05;
var z:Number = 1; // 1 ist so, dass man alles sieht
var x:Number = .5; // 0 ist links - 1 ist rechts
var y:Number = .5; // 0 ist oben - 1 ist unten
var contSkal:Number = container._width / container._height;
var maskSkal:Number = mask._width / mask._height;
var showAllWidth:Number = contSkal > maskSkal ? mask._width : mask._height * contSkal;
var showAllHeight:Number = showAllWidth / contSkal;
function updateZoom() {
container._width = showAllWidth * z;
container._height = showAllHeight * z;
}
function updatePosition() {
container._x = Math.floor(mask._x + (mask._width - container._width) * x);
container._y = Math.floor(mask._y + (mask._height - container._height) * y);
}
function updateSlider() {
var rel:Number = (z - minZoom) / (maxZoom - minZoom);
slider.dragger._y = slider.track._y + (slider.track._height - slider.dragger._height) * rel;
}
updateZoom();
updatePosition();
updateSlider();
// Dragging
container.onPress = function() {
this.startDrag(
false,
mask._x + mask._width - container._width,
mask._y + mask._height - container._height,
mask._x,
mask._y
);
this.onMouseMove = function() {
if (Math.abs(container._width - mask._width) > 3) {
x = (container._x - mask._x) / (mask._width - container._width);
x = Math.max(0, Math.min(1, x));
}
if (Math.abs(container._height - mask._height) > 3) {
y = (container._y - mask._y) / (mask._height - container._height);
y = Math.max(0, Math.min(1, y));
}
}
//Mauszeiger
Mouse.hide();
this.text_feld.startDrag(true);
this.text_feld._visible = true;
}
container.onRelease = container.onReleaseOutside = function() {
stopDrag();
delete this.onMouseMove;
//Mauszeiger
Mouse.show();
this.text_feld.stopDrag();
this.text_feld._visible = false;
}
// Slider
slider.dragger.onPress = function() {
this.startDrag(false, this._x, this._parent.track._y, this._x, this._parent.track._y + this._parent.track._height - this._height);
this.onMouseMove = function() {
var rel:Number = (slider.dragger._y - slider.track._y) / (slider.track._height - slider.dragger._height);
z = minZoom + rel * (maxZoom - minZoom);
updateZoom();
updatePosition();
};
};
slider.dragger.onRelease = slider.dragger.onReleaseOutside = function () {
stopDrag();
delete this.onMouseMove;
};
*/