Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 24-01-2006, 08:32   #1 (permalink)
flashen-lehr
 
Benutzerbild von michey
 
Registriert seit: Dec 2004
Ort: CH, Europa
Beiträge: 1.681
AS Anfängerfrage

Ich möchte dieses Script gleichzeitig auf mehrere einzelne mcs (mc1, mc2,mc3,mc4) anwenden (zuweisen), ohne jedoch die mcs in ein movie zusammenzufassen (was ja der einfachst Weg wäre).
Das naheliegendeste für ein dummy wäre ja das script für jeden mc wiederholen.
Aber man kann das Ganze sicher auch zusammenfassen.
Nur, wie geht das?

PHP-Code:
1024;
// Stage-Breite
760;
// Stage-Höhe
this.mc1.soft 20;
this.mc1.mc1._x;
this.mc1.mc1._y;
this.mc1.onEnterFrame= function() {
    
with (this) {
        
= (x*soft+_root._xmouse)/(soft+1);
        
= (y*soft+_root._ymouse)/(soft+1);
        
_x 1024/3-x;
        
_y 760/2-y;
    }
};
// Grenzen setzen
if (this._x<0) {
    
this.mc1._x 0;
}
if (
this._x>_global.w) {
    
this.mc1._x _global.w;
}
if (
this._y<0) {
    
this.mc1._y 0;
}
if (
this._y>_global.h) {
    
this.mc1._y _global.h;

__________________
michey
michey ist offline   Mit Zitat antworten
Alt 24-01-2006, 08:36   #2 (permalink)
tracer
 
Benutzerbild von andretti
 
Registriert seit: Jun 2004
Beiträge: 4.415
aloha!

was genau willst du erreichen?
dass sich mehrere mc's zu einer jeweiligen bestimmten position bewegen?
__________________
Viola per Sempre
Alle Angaben ohne Gewehr!
trace your open mind in variables !
andretti
ActionScript Dictionary
andretti ist offline   Mit Zitat antworten
Alt 24-01-2006, 08:46   #3 (permalink)
flashen-lehr
 
Benutzerbild von michey
 
Registriert seit: Dec 2004
Ort: CH, Europa
Beiträge: 1.681
Aloha

Ich hattte es mir gerade noch verkneift zu schreiben: Danke, andretti.
Du scheinst in jeder Beziehung very fix zu sein.

Also, die clips liegen schon an verschidenen Positionen und sollen dann alle mit dem script gleichzeitig bewegt werden.
Ich möchte eigentlich nur wissen wie ich das script umschreiben muss, damit ich mehrere mcs ansprechen kann.
__________________
michey
michey ist offline   Mit Zitat antworten
Alt 24-01-2006, 08:50   #4 (permalink)
°.oO°O.o°.oO.o°O
 
Benutzerbild von bamboocha
 
Registriert seit: Jun 2005
Ort: CH
Beiträge: 1.490
setz das onEnterFrame auf this und wende die Move-Befehle in ner for-Schleife an!
__________________
There is no way to happiness, happiness is the way! - Buddha
bamboocha ist offline   Mit Zitat antworten
Alt 24-01-2006, 09:01   #5 (permalink)
flashen-lehr
 
Benutzerbild von michey
 
Registriert seit: Dec 2004
Ort: CH, Europa
Beiträge: 1.681
Danke, bamboocha!

Klappt auch ohne for- Schleife.
Wofür wäre denn die Schleife?
__________________
michey
michey ist offline   Mit Zitat antworten
Alt 24-01-2006, 09:13   #6 (permalink)
°.oO°O.o°.oO.o°O
 
Benutzerbild von bamboocha
 
Registriert seit: Jun 2005
Ort: CH
Beiträge: 1.490
damit du alle MC's auf einmal ansprechen kannst! Spart Schreibarbeit!
PHP-Code:
1024;
// Stage-Breite 
760;
// Stage-Höhe 
anzahl 10;
//Anzahl MC's
for (var 1i<anzahli++) {
    
this["mc"+i].soft 20;
    
this["mc"+i].this["mc"+i]._x;
    
this["mc"+i].this["mc"+i]._y;
    
this["mc"+i].onEnterFrame = function() {
        
this.= (this.x*this.soft+_root._xmouse)/(this.soft+1);
        
this.= (this.y*this.soft+_root._ymouse)/(this.soft+1);
        
this._x _root.w/3-this.x;
        
this._y _root.h/2-this.y;
        
// Grenzen setzen 
        
if (this._x<0) {
            
this._x 0;
        }
        if (
this._x>_root.w) {
            
this._x _root.w;
        }
        if (
this._y<0) {
            
this._y 0;
        }
        if (
this._y>_root.h) {
            
this._y _root.h;
        }
    };

__________________
There is no way to happiness, happiness is the way! - Buddha

Geändert von bamboocha (24-01-2006 um 09:16 Uhr)
bamboocha ist offline   Mit Zitat antworten
Alt 24-01-2006, 09:21   #7 (permalink)
flashen-lehr
 
Benutzerbild von michey
 
Registriert seit: Dec 2004
Ort: CH, Europa
Beiträge: 1.681
Vielen Dank!

Ja, genau das hatte ich gesucht.
Hätte eigentlich selbst darauf kommen können/müssen.

Aber ist vielleicht noch etwas früh dazu...
__________________
michey
michey ist offline   Mit Zitat antworten
Alt 24-01-2006, 09:22   #8 (permalink)
°.oO°O.o°.oO.o°O
 
Benutzerbild von bamboocha
 
Registriert seit: Jun 2005
Ort: CH
Beiträge: 1.490
Naja... wird schon!
btw. Gruss nach Herzogenbuchsee aus Zollikofen!
__________________
There is no way to happiness, happiness is the way! - Buddha
bamboocha ist offline   Mit Zitat antworten
Alt 24-01-2006, 10:05   #9 (permalink)
flashen-lehr
 
Benutzerbild von michey
 
Registriert seit: Dec 2004
Ort: CH, Europa
Beiträge: 1.681
Hey, danke für die Grüsse, aber woher hast du das Herzogenbuchsee?

Übe jetzt am Gegenteil von oben (mcs einzeln, unabhängig voneinander mit jeweils etwas andere Einstellungen soft moven plus Zusätze).
Aber beim Rollover wird das moven gestoppt.
Woran liegt das?

PHP-Code:
1024;
// Stage-Breite
h760;
// Stage-Höhe
mc1.soft 20;
mc1.mc1._x;
mc1.mc1._y;
mc1.onEnterFrame = function() {
    
with (this) {
        
= (x*soft+_root._xmouse)/(soft+1);
        
= (y*soft+_root._ymouse)/(soft+1);
        
_x 1024/3-x;
        
_y 760/2-y;
    }
};
// Grenzen setzen
if (this._x<0) {
    
mc1._x 0;
}
if (
this._x>w) {
    
mc1._x =w;
}
if (
this._y<0) {
    
mc1._y 0;
}
if (
this._y>h) {
    
mc1._y =h;
}


MovieClip.prototype.bounce = function(pWertpMult_neupMult_alt) {
    
this.faktor_neu 0;
    
this.onEnterFrame = function() {
        
this.faktor_alt = -this._yscale+pWert;
        
this.faktor_neu Math.round(this.faktor_neu*pMult_neu+this.faktor_alt*pMult_alt);
        
this._yscale += this.faktor_neu;
        
this._xscale this._yscale;
        if (
this._yscale == pWert) {
            
delete this.onEnterFrame;
        }
    };
    
ASSetPropFlags(MovieClip.prototype"bounce"1);
};
zaehler 4;
// Clip 1
mc1.onRollOver = function() {
    
mx.transitions.TransitionManager.start(mc1, {type:mx.transitions.PhotostartPoint:empty, numStrips:empty, dimension:empty, direction:0ccw:empty, duration:1shape:empty, xSections:empty, ySections:empty, easing:mx.transitions.easing.Bounce.easeOutparam1:empty, param2:empty});
    
this.bounce(1250.80.5);
    
this.swapDepths(zaehler++);
};
this.mc1.onRollOut = function() {
    
this.bounce(1000.80.5);
};
mc2.onRollOver = function() {
    
mx.transitions.TransitionManager.start(mc2, {type:mx.transitions.PhotostartPoint:empty, numStrips:empty, dimension:empty, direction:0ccw:empty, duration:1shape:empty, xSections:empty, ySections:empty, easing:mx.transitions.easing.Bounce.easeOutparam1:empty, param2:empty});
    
this.bounce(1250.80.5);
    
this.swapDepths(zaehler++);
};
this.mc2.onRollOut = function() {
    
this.bounce(1000.80.5);
};
mc3.onRollOver = function() {
    
mx.transitions.TransitionManager.start(mc3, {type:mx.transitions.PhotostartPoint:empty, numStrips:empty, dimension:empty, direction:0ccw:empty, duration:1shape:empty, xSections:empty, ySections:empty, easing:mx.transitions.easing.Bounce.easeOutparam1:empty, param2:empty});
    
this.bounce(1250.80.5);
    
this.swapDepths(zaehler++);
};
this.mc3.onRollOut = function() {
    
this.bounce(1000.80.5);
};
mc4.onRollOver = function() {
    
mx.transitions.TransitionManager.start(mc4, {type:mx.transitions.PhotostartPoint:empty, numStrips:empty, dimension:empty, direction:0ccw:empty, duration:1shape:empty, xSections:empty, ySections:empty, easing:mx.transitions.easing.Bounce.easeOutparam1:empty, param2:empty});
    
this.bounce(1250.80.5);
    
this.swapDepths(zaehler++);
};
this.mc4.onRollOut = function() {
    
this.bounce(1000.80.5);
}; 
Angehängte Dateien
Dateityp: zip MOVE_TEST.zip (5,6 KB, 7x aufgerufen)
__________________
michey
michey ist offline   Mit Zitat antworten
Alt 24-01-2006, 10:22   #10 (permalink)
°.oO°O.o°.oO.o°O
 
Benutzerbild von bamboocha
 
Registriert seit: Jun 2005
Ort: CH
Beiträge: 1.490
Dein Portfolio!

Weil du beim RollOver das onEnterFrame überschreibst!
PHP-Code:
mc1.onEnterFrame = function() { 
    
with (this) { 
        
= (x*soft+_root._xmouse)/(soft+1); 
        
= (y*soft+_root._ymouse)/(soft+1); 
        
_x 1024/3-x
        
_y 760/2-y
    } 
}; 
//später:
mc1.onRollOver = function() { 
    
//...
    
this.bounce(1250.80.5); //--> darin:
    //...
};
MovieClip.prototype.bounce = function(pWertpMult_neupMult_alt) { 
    
//bla bla
    
this.onEnterFrame = function() { 
    
//bla bla...
}; 
__________________
There is no way to happiness, happiness is the way! - Buddha
bamboocha ist offline   Mit Zitat antworten
Alt 24-01-2006, 10:29   #11 (permalink)
flashen-lehr
 
Benutzerbild von michey
 
Registriert seit: Dec 2004
Ort: CH, Europa
Beiträge: 1.681
Also ist die bounce Funktion schuld.
Und wie kann ich das umgehen und das Bouncen beibehalten?
__________________
michey
michey ist offline   Mit Zitat antworten
Alt 24-01-2006, 10:33   #12 (permalink)
°.oO°O.o°.oO.o°O
 
Benutzerbild von bamboocha
 
Registriert seit: Jun 2005
Ort: CH
Beiträge: 1.490
Lass das onEnterFrame mit allen Funktionen, die du brauchen wirst, laufen. Erstelle allerdings ne if-Abfrage vor jeder Funktion und überprüf, ob die entsprechende Variable gesetzt ist!

Bsp:
PHP-Code:
this.onEnterFrame = function() {
    if(
_global.bounceit == true) {
         
this.bounce();
    }
    if(
_global.hide == true) {
         
this.hide();
    }
    
//...etc.
}

this.btn.onPress = function() {
_global.bounceit true;

Allerdings müsstest du dann eben das onEnterFrame von Bounce entfernen!
__________________
There is no way to happiness, happiness is the way! - Buddha
bamboocha ist offline   Mit Zitat antworten
Alt 24-01-2006, 10:38   #13 (permalink)
flashen-lehr
 
Benutzerbild von michey
 
Registriert seit: Dec 2004
Ort: CH, Europa
Beiträge: 1.681
Merci!
Werds dann heute Abend versuchen.

Schönen Tag noch.
__________________
michey
michey ist offline   Mit Zitat antworten
Alt 24-01-2006, 20:25   #14 (permalink)
flashen-lehr
 
Benutzerbild von michey
 
Registriert seit: Dec 2004
Ort: CH, Europa
Beiträge: 1.681
Hab das so verstanden und versucht:

PHP-Code:
MovieClip.prototype.bounce = function(pWertpMult_neupMult_alt) {
    
this.faktor_neu 0;
    
this.faktor_alt = -this._yscale+pWert;
    
this.faktor_neu Math.round(this.faktor_neu*pMult_neu+this.faktor_alt*pMult_alt);
    
this._yscale += this.faktor_neu;
    
this._xscale this._yscale;
    if (
this._yscale == pWert) {
    }
    
ASSetPropFlags(MovieClip.prototype"bounce"1);
};

800;
// Stage-Breite
600;
// Stage-Höhe
mc1.soft 20;
mc1.mc1._x;
mc1.mc1._y;
mc1.onEnterFrame = function() {
    
with (mc1) {
        
= (x*soft+_root._xmouse)/(soft+2);
        
= (y*soft+_root._ymouse)/(soft+2);
        
_x 1024/3-x;
        
_y 760/2-y;
    }
};
if (
_global.bounceit == true) {
    
this.bounce(1250.80.5);
}
if (
_global.bounceback == true) {
    
this.bounce(1000.80.5);
}
// Grenzen setzen
if (mc1._x<0) {
    
mc1._x 0;
}
if (
mc1._x>w) {
    
mc1._x w;
}
if (
mc1._y<0) {
    
mc1._y 0;
}
if (
mc1._y>h) {
    
mc1._y h;
}
zaehler 4;
// Clip 1
mc1.onRollOver = function() {
    
mx.transitions.TransitionManager.start(mc1, {type:mx.transitions.PhotostartPoint:empty, numStrips:empty, dimension:empty, direction:0ccw:empty, duration:1shape:empty, xSections:empty, ySections:empty, easing:mx.transitions.easing.Bounce.easeOutparam1:empty, param2:empty});
    
_global.bounceit true;
    
this.swapDepths(zaehler++);
};
mc1.onRollOut = function() {
    
_global.bounceback true;
}; 
Aber keine Spur von bouncen!
__________________
michey
michey ist offline   Mit Zitat antworten
Alt 24-01-2006, 20:34   #15 (permalink)
°.oO°O.o°.oO.o°O
 
Benutzerbild von bamboocha
 
Registriert seit: Jun 2005
Ort: CH
Beiträge: 1.490
könnte es sein, dass sich die Werte von bounce und bounceback überschreiben!? Versuch mal den anderen Wert auf false zu setzen, wenn du den jeweiligen auf true setzt!
__________________
There is no way to happiness, happiness is the way! - Buddha
bamboocha 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 08:40 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele