Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 08-01-2006, 19:47   #1 (permalink)
Neuer User
 
Registriert seit: Oct 2005
Beiträge: 61
dynamische MCs

Hallo

Ich habe schon folgendes script geschrieben und nun möchte ich aber noch, dass die Buttons in ihre Ausgangsposition zurück gehen wenn man einen anderen Button drückt.
Außerdem wollte ich noch wissen wie ich das allgemeiner schreiben kann, damit ich später mehrere Buttons einfügen kann?
Ich hoffe es ist einigermaßen verständlich was ich will.
PHP-Code:
_root.button01_mc.onRelease = function() {
    
_root.button01_mc.onEnterFrame = function() {
        
this._xscale += ((150-this._xscale)/5);
        
this._rotation += ((90-this._rotation)/5);
        
this._x += ((150-this._x)/5);
    };
};
_root.button02_mc.onRelease = function() {
    
_root.button02_mc.onEnterFrame = function() {
        
this._xscale += ((150-this._xscale)/5);
        
this._rotation += ((90-this._rotation)/5);
        
this._x += ((150-this._x)/5);
    };
}; 
Danke im voraus
mouzZ ist offline   Mit Zitat antworten
Alt 08-01-2006, 20:05   #2 (permalink)
notzucht
 
Benutzerbild von shorty
 
Registriert seit: Nov 2003
Ort: Potsdam
Beiträge: 2.939
wenn du dich bei der benennung der movieclip instanzen an ein paar regeln hältst, geht das dynamische zuweisen von eventHandlern ganz easy per "for" schleife.

Angenommen in der _root deines filmes sind 10 movieclips mit namen mcTest0 - mcTest10. dann könnte die schleife zur dynamischen eventbelegung der buttons so aussehen:
PHP-Code:
for (var 0<= 10i++) {
   
_root['mcTest' i].onRelease = function () {
      
foo(this);
   };

die function, um deine bewegung, o.ä. aufzurufen, deklarierst du separat:
PHP-Code:
function foo (instance:MovieClip) : Void {
   
instance.onEnterFrame = function () {
        
this._xscale += ((150-this._xscale)/5); 
        
this._rotation += ((90-this._rotation)/5); 
        
this._x += ((150-this._x)/5); 
   }

__________________
.
Flex in a week | Viertel vor halb nach Vollmond | ^^°.°^^ | Waltz with Bashir
.

Geändert von shorty (08-01-2006 um 20:11 Uhr)
shorty ist offline   Mit Zitat antworten
Alt 09-01-2006, 11:53   #3 (permalink)
Neuer User
 
Registriert seit: Oct 2005
Beiträge: 61
Danke!!
Damit hast du mir schon mal gut geholfen, aber wie mach ich das nun, dass die MCs zurück in ihre Ausgangsposition gehen wenn man einen anderen mc anklickt?

greez mouzZ
mouzZ ist offline   Mit Zitat antworten
Alt 09-01-2006, 12:11   #4 (permalink)
................
 
Benutzerbild von Der Frager
 
Registriert seit: Jun 2004
Beiträge: 15.890
Hallo!
Kannst du mal so probieren:
PHP-Code:
for (var 0i<=10i++) {
    
_root['mcTest'+i].onRelease = function() {
        if (
_root.lastMC != this) {
            
_root.lastMC.foo(_root.lastMC.x0100);
            
_root.lastMC this;
            
_root.lastMC.this._x;
            
this.foo(15090150);
        }
    };
}
MovieClip.prototype.foo = function(xrotscal) {
    
this.onEnterFrame = function() {
        
this._xscale += (scal-this._xscale)/5;
        
this._rotation += (rot-this._rotation)/5;
        
this._x += (x-this._x)/5;
        if (
Math.round(this._rotation) == rot) {
            
this._xscale scal
            this
._x x
            this
._rotation rot
            delete this
.onEnterFrame;
            
        }
    };
}; 
__________________

ternärer Konditionaloperator

+++ Bitte keine Privat-Nachrichten bezüglich Flashfragen! +++
Der Frager ist offline   Mit Zitat antworten
Alt 09-01-2006, 14:52   #5 (permalink)
Neuer User
 
Registriert seit: Oct 2005
Beiträge: 61
gut jetzt gehts!!

Jetzt hab ich aber nen neues problem
Ich hab ein mc erstellt und darauf dann die button_mc´s mit dem code von oben gepackt.
In dan anderen mc hab ich folgendes schrieben:
PHP-Code:
_root.bar._x xbar=50;
_root.bar.onRollOver = function() {
    
_root.bar.onEnterFrame = function() {
        
_root.bar._x += (200-_root.bar._x)/5;
            
    };
};
_root.bar.onRollOut = function() {
    
_root.bar.onEnterFrame = function() {
        
_root.bar._x += (xbar-_root.bar._x)/5;
        
    };
    
}; 
aber jetzt funktionieren und "button"-mc´s nicht mehr??
mouzZ ist offline   Mit Zitat antworten
Alt 09-01-2006, 15:59   #6 (permalink)
................
 
Benutzerbild von Der Frager
 
Registriert seit: Jun 2004
Beiträge: 15.890
Ja, weil dein RollOver/RollOut die Mausevents abfängt. So ginge das aber:
PHP-Code:
_root.bar._x xbar=50;
_root.bar.onEnterFrame = function() {
    if (
this.hitTest(_root._xmouse_root._ymouse)) {
        
this._x += (200-this._x)/5;
    } else {
        
this._x += (xbar-this._x)/5;
    }
}; 
__________________

ternärer Konditionaloperator

+++ Bitte keine Privat-Nachrichten bezüglich Flashfragen! +++
Der Frager ist offline   Mit Zitat antworten
Alt 10-01-2006, 15:27   #7 (permalink)
Neuer User
 
Registriert seit: Oct 2005
Beiträge: 61
ok...
Wenn ich jetzt die buttons anklicke funktioniert alles, aber ich möchte noch das die mc´s immer auf einer höhe sind nachdem man sie angeklickt hat. Hab das folgender maßen gemacht

PHP-Code:
onClipEvent (load) {
    for (var 
0i<=10i++) {
        
_root.bar['button'+i].onRelease = function() {
            if (
_root.bar.lastMC != this) {
                
_root.bar.lastMC.foo(_root.bar.lastMC.x0100100y);
                
_root.bar.lastMC this;
                
_root.bar.lastMC.this._x;
                
_root.bar.lastMC.this._y;
                
this.foo(1959029020010);
            }
        };
    }
    
MovieClip.prototype.foo = function(xrotscalycaly) {
        
this.onEnterFrame = function() {
            
this._yscale += (ycal-this._yscale)/5;
            
this._xscale += (scal-this._xscale)/5;
            
this._rotation += (rot-this._rotation)/5;
            
this._x += (x-this._x)/5;
            
this._y += (y-this._y)/5;
            if (
Math.round(this._rotation) == rot) {
                
this._xscale scal;
                
this._yscale ycal;
                
this._x x;
                
this._y y;
                
this._rotation rot;
                
delete this.onEnterFrame;
            }
        };
    };

aber nun gehen die mc´s nicht auf ihre alte position zurück, sondern immer auf die position des ersten mc´s?
mouzZ ist offline   Mit Zitat antworten
Alt 10-01-2006, 15:35   #8 (permalink)
................
 
Benutzerbild von Der Frager
 
Registriert seit: Jun 2004
Beiträge: 15.890
PHP-Code:
_root.bar.lastMC.foo(_root.bar.lastMC.x0100100_root.bar.lastMC.y); 
__________________

ternärer Konditionaloperator

+++ Bitte keine Privat-Nachrichten bezüglich Flashfragen! +++
Der Frager ist offline   Mit Zitat antworten
Alt 10-01-2006, 15:40   #9 (permalink)
Neuer User
 
Registriert seit: Oct 2005
Beiträge: 61
danke
mouzZ ist offline   Mit Zitat antworten
Alt 10-01-2006, 15:41   #10 (permalink)
................
 
Benutzerbild von Der Frager
 
Registriert seit: Jun 2004
Beiträge: 15.890
Bitte . Versuch mal, den Code ein wenig zu verstehen. Dann wärst du da auch selber drauf gekommen...
__________________

ternärer Konditionaloperator

+++ Bitte keine Privat-Nachrichten bezüglich Flashfragen! +++
Der Frager ist offline   Mit Zitat antworten
Alt 10-01-2006, 15:57   #11 (permalink)
Neuer User
 
Registriert seit: Oct 2005
Beiträge: 61
Joa ich versteh den schon.. ich komm noch nich immer drauf wie ich was wo ändern muss
mouzZ 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 05:11 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele