Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 13-02-2006, 04:56   #1 (permalink)
Neuer User
 
Benutzerbild von Gleis3
 
Registriert seit: Aug 2003
Ort: Reutlingen
Beiträge: 23
RollOver Funktionen in einer Schleife

Hi Leute ...

ich sitz schon die halbe Nacht hier und hab nun mehrere Versionen ausprobiert aber keine will so wie mein logischer Menschenverstand mir das vorgaukelt ...

ich hab folgende Zeilen in meinem Script die mehrere Buttons (in diesem Fall lediglich Movieclips) mit den dazugehörigen Bezeichnungen generieren. Die Bezeichnungen werden aus einem Array geladen.

PHP-Code:
for (var b=1;b<anz+1;b++) {    
    
this.Inhalt.createEmptyMovieClip("buttonmc_"+b,100+b);    
        
this.Inhalt["buttonmc_"+b].attachMovie("sf2","button_"+b,200+b,{_x:212,_y:start_y-3,_alpha:0});
        
this.Inhalt["buttonmc_"+b].createTextField("buttontext_"+b,1,212,start_y,180,24);
        
this.Inhalt["buttonmc_"+b]["buttontext_"+b].embedFonts true;
        
this.Inhalt["buttonmc_"+b]["buttontext_"+b].selectable false;
        
this.Inhalt["buttonmc_"+b]["buttontext_"+b].text arrayname[b-1];
        
this.Inhalt["buttonmc_"+b]["buttontext_"+b].setTextFormat(ButtonFormat);
        
this.Inhalt["buttonmc_"+b]["buttontext_"+b]._alpha=50;
        
start_y start_y+_global.linedup;
    }; 
_global.linedup = 24 ( damit die Buttons alle 24 Pixel ausgehend von _y gesetzt werden. Die einzelnen Parameter übergebe ich in einem Initialisierungsobjekt am Anfang der Funktion.

Jetzt zur Frage ... ist es möglich folgende Buttonfunktionen auch per Schleife zu generieren oder muss ich das wirklich für jeden Button einzeln machen ?
Der Code momentan (funktioniert bestens aber ist halt nicht wirklich "dynamisch") ...

PHP-Code:
// Button 1    
    
_root.Inhalt.buttonmc_1.button_1.onRollOver = function() {
        
_root.Inhalt.buttonmc_1.buttontext_1.alphaTo(1000.2"easeOutQuad");
    };
    
_root.Inhalt.buttonmc_1.button_1.onRollOut = function() {
        
_root.Inhalt.buttonmc_1.buttontext_1.alphaTo(500.2"easeOutQuad");
    };
    
// Button 2    
    
_root.Inhalt.buttonmc_2.button_2.onRollOver = function() {
        
_root.Inhalt.buttonmc_2.buttontext_2.alphaTo(1000.2"easeOutQuad");
    };
    
_root.Inhalt.buttonmc_2.button_2.onRollOut = function() {
        
_root.Inhalt.buttonmc_2.buttontext_2.alphaTo(500.2"easeOutQuad");
    };

// ... usw bis Button 6 
Vielleicht kann ja jemand meinen bescheidenen Actionscript Kenntnissen weiterhelfen ...
__________________
GLEIS DREI
Gleis3 ist offline   Mit Zitat antworten
Alt 13-02-2006, 07:01   #2 (permalink)
Definitionssache
 
Benutzerbild von dburucu
 
Registriert seit: Apr 2003
Ort: Braunschweig
Beiträge: 2.433
so sollte es gehen:

Code:
for (var b=1;b<anz+1;b++) {    
    this.Inhalt.createEmptyMovieClip("buttonmc_"+b,100+b);    
//------------------------------
        this.Inhalt["buttonmc_"+b].b = b;
//------------------------------
        this.Inhalt["buttonmc_"+b].attachMovie("sf2","button_"+b,200+b,{_x:212,_y:start_y-3,_alpha:0});
        this.Inhalt["buttonmc_"+b].createTextField("buttontext_"+b,1,212,start_y,180,24);
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].embedFonts = true;
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].selectable = false;
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].text = arrayname[b-1];
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].setTextFormat(ButtonFormat);
        this.Inhalt["buttonmc_"+b]["buttontext_"+b]._alpha=50;
        start_y = start_y+_global.linedup;

        this.Inhalt["buttonmc_"+b]["buttontext_"+b].onRollOver = function() {
        this._parent["buttontext_"+this._parent.b].alphaTo(100, 0.2, "easeOutQuad");
    }; 
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].onRollOut = function() {
        this._parent["buttontext_"+this._parent.b].alphaTo(50, 0.2, "easeOutQuad");
    }; 

};
ich weiss aber nicht, wieso du die Buttontexte auch durchnummeriert hast, obwohl die eigentlich zu einer buttonmc zugeordnet sind.
dburucu ist offline   Mit Zitat antworten
Alt 13-02-2006, 10:57   #3 (permalink)
Neuer User
 
Benutzerbild von Gleis3
 
Registriert seit: Aug 2003
Ort: Reutlingen
Beiträge: 23
Zitat:
Zitat von dburucu
so sollte es gehen:

Code:
for (var b=1;b<anz+1;b++) {    
    this.Inhalt.createEmptyMovieClip("buttonmc_"+b,100+b);    
//------------------------------
        this.Inhalt["buttonmc_"+b].b = b;
//------------------------------
        this.Inhalt["buttonmc_"+b].attachMovie("sf2","button_"+b,200+b,{_x:212,_y:start_y-3,_alpha:0});
        this.Inhalt["buttonmc_"+b].createTextField("buttontext_"+b,1,212,start_y,180,24);
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].embedFonts = true;
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].selectable = false;
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].text = arrayname[b-1];
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].setTextFormat(ButtonFormat);
        this.Inhalt["buttonmc_"+b]["buttontext_"+b]._alpha=50;
        start_y = start_y+_global.linedup;

        this.Inhalt["buttonmc_"+b]["buttontext_"+b].onRollOver = function() {
        this._parent["buttontext_"+this._parent.b].alphaTo(100, 0.2, "easeOutQuad");
    }; 
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].onRollOut = function() {
        this._parent["buttontext_"+this._parent.b].alphaTo(50, 0.2, "easeOutQuad");
    }; 

};
ich weiss aber nicht, wieso du die Buttontexte auch durchnummeriert hast, obwohl die eigentlich zu einer buttonmc zugeordnet sind.
Weil ich die einzelnen Buttontexte einblenden lasse und ich (nahc meinem logischen Denken) alle Buttontexte einblenden lassen würde. Aber eigentlich könnte ich auch den ganzen MC einblenden lassen und nur die MC-Schaltfläche weiterhin auf alpha=0 setzen. ... Mal rumexperimentieren ... Das mit deinem Ansatz hat übrigens nicht so funktioniert aber ich versuche es trotzdem weiter ...

danke trotzdem ... ich halt dich auf dem laufenden ...

Karsten
__________________
GLEIS DREI
Gleis3 ist offline   Mit Zitat antworten
Alt 13-02-2006, 12:50   #4 (permalink)
Definitionssache
 
Benutzerbild von dburucu
 
Registriert seit: Apr 2003
Ort: Braunschweig
Beiträge: 2.433
hmmm komisch.

hast den oberen Teil auch nicht vergessen?
this.Inhalt["buttonmc_"+b].b = b;



ehm ich sehe gerade... sollte es denn nicht so funktionieren?

Code:
for (var b=1;b<anz+1;b++) {    
    this.Inhalt.createEmptyMovieClip("buttonmc_"+b,100+b);    
//------------------------------
        this.Inhalt["buttonmc_"+b].b = b;
//------------------------------
        this.Inhalt["buttonmc_"+b].attachMovie("sf2","button_"+b,200+b,{_x:212,_y:start_y-3,_alpha:0});
        this.Inhalt["buttonmc_"+b].createTextField("buttontext_"+b,1,212,start_y,180,24);
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].embedFonts = true;
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].selectable = false;
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].text = arrayname[b-1];
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].setTextFormat(ButtonFormat);
        this.Inhalt["buttonmc_"+b]["buttontext_"+b]._alpha=50;
        start_y = start_y+_global.linedup;

        this.Inhalt["buttonmc_"+b]["buttontext_"+b].onRollOver = function() {
        this.alphaTo(100, 0.2, "easeOutQuad");
    }; 
        this.Inhalt["buttonmc_"+b]["buttontext_"+b].onRollOut = function() {
        this.alphaTo(50, 0.2, "easeOutQuad");
    }; 

};
dburucu 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 03:25 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele