Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 30-05-2006, 14:15   #1 (permalink)
Querdenker
 
Registriert seit: Aug 2003
Ort: Berlin
Beiträge: 32
preloader function - loadmovie ersatz, funktioniert nicht

Hallo zusammen,

es geht um folgendes, wie ihr sieht ist dies eine kleine xml projekte galerie, die navigationspunkte werden dynamisch ausgelesen und erzeugt und die bilder tumbnails, nun würde ich gerne statt den loadmovie befehl zu nehmen es so hinwursteln, das diese bilder preloaded werden und sobald sie fertig geladen sind schön einfaden.

ich habe aber leider keine ahnung an was das problem liegt... ziemlich weit unten ich habe es eh kommentiert.

vielen dank im vorraus,

liebe grüsse,

stefan


PHP-Code:
// Fade in Fade Out Funktion
this._lockroot true;

MovieClip.prototype.fadinout = function(iofastbr) { 
    var 
mc this
    var 
0
    
delete mc.onEnterFrame
    if(
io){ 
        
mc.onEnterFrame = function(){ 
            
i+=br 
            mc
._alpha-=(st*i); 
            if (
mc._alpha<=fa){ 
                
delete mc.onEnterFrame
                
mc._alpha=fa
            }                                       
        }; 
    }else if(!
io){ 
        
mc.onEnterFrame=function(){ 
           
i+=br
            
mc._alpha+=(st*i); 
            if (
mc._alpha>=fa){ 
                
delete mc.onEnterFrame
            }                                       
        }; 
    }  
}  



//TextFormat für buttons
var buttonOut_fmt:TextFormat = new TextFormat();
buttonOut_fmt.font "boutiqdince";
buttonOut_fmt.size 11;
buttonOut_fmt.color 0xFFFFFF;

var 
buttonOn_fmt:TextFormat = new TextFormat();
buttonOn_fmt.font "boutiqdincebold";
buttonOn_fmt.size 11;
buttonOn_fmt.color 0xFFFFFF;

// Diese Funktion Ladet die XML Daten in mehrdimensionale Arrays
function loadXML(loaded) { 
        if (
loaded) { 
            
xmlNode this.firstChild
            
_global.ProjekteArray = []; 
            
_global.BilderArray = [];
             
ProjekteTotal xmlNode.childNodes.length
             
// Setze H Counter auf 0 um unabhaengige Array IDS zu erstellen
            
h=0;
            
// Alle Projekte durchlaufen lassen und ordnen
            
for (i=0i<ProjekteTotali++) { 
                
ProjekteArray[i] = [[i],[xmlNode.childNodes[i].attributes.titel],[xmlNode.childNodes[i].attributes.ort],[xmlNode.childNodes[i].attributes.hauptbild]]; 
                
currentMAX xmlNode.childNodes[i].childNodes[1].childNodes.length;
                
// Alle Bilder aus dem momentan Durchlaufendem Projekt beziehen
                
for (k=0k<xmlNode.childNodes[i].childNodes[1].childNodes.lengthk++) { 
                        
BilderArray[h] = [[i],[xmlNode.childNodes[i].childNodes[1].childNodes[k].attributes.name],[xmlNode.childNodes[i].childNodes[1].childNodes[k].attributes.pic]]; 
                        
h+1;
                }
            }

            
// Wenn alles geladen ist Verarbeite die Klassen
            
getDataByXML();
            
// nächster funktionsaufruf 
        
} else { 
            
content "Fehler!!!!"
        } 


xmlData = new XML(); 
xmlData.ignoreWhite true
xmlData.onLoad loadXML;
//xmlData.load(_global.currentxml);  
xmlData.load("inhalt.xml");  

// Diese Funktion erstellt die Buttons und auf den Schaltflaechen
// wird nachher per onRelease die Funktion aufgerufen um die Bilder zu laden
function getDataByXML() {
// Projektnamen buttons erstellen
        
projekte_dis _global.ProjekteArray.length;
        for (var 
s=0s<projekte_diss++) {  
            
            var 
w:Number 100;
            var 
h:Number 20;
            var 
bgColor_normal:Number 0x911201;
            var 
bgColor_hover:Number 0x911201;

            var 
cont:MovieClip createEmptyMovieClip("container"+sthis.getNextHighestDepth());
            
cont.beginFill(bgColor_normal);
            
cont.lineTo(w0);
            
cont.lineTo(wh);
            
cont.lineTo(0h);
            
cont.lineTo(00);
            
cont._x 38;
            
cont._y 338 s*(h+1);
            
cont.createTextField("teext"+ss1010this.getNextHighestDepth());  

            
cont["teext"+s].text _global.ProjekteArray[s][1];
            
cont["teext"+s].autoSize true;
            
cont["teext"+s].embedFonts true;
            
cont["teext"+s].antiAliasType "advanced";
            
cont["teext"+s].selectable true;
            
cont["teext"+s].setTextFormat(buttonOut_fmt);
            
// Button Erstellung und Verweiss auf Datenfunktionen erstellen
            
cont.number s;
            
            
            
cont.onRelease = function() { 
                if(
_global.lastclicked != this.number) {
                
loadPictureData(_global.ProjekteArray[this.number][0]);
                
                
// Remove the movieeeeclips baby
                
removeMovieClip(_root["bildnavcont"+_global.projektid2]);
                
removeMovieClip(_root["hauptbild"+_global.projektid2]);
                
this._alpha=100;
                
                
// Yeah give me the effects babybaby oh baby!
                
_root["container"+this.number]["teext"+this.number].setTextFormat(buttonOn_fmt);
                
_root["container"+projektid2]["teext"+projektid2].setTextFormat(buttonOut_fmt);
                
_root["container"+projektid2].fadinout(1,50,2,1);
                
                
// Last clicked link
                
_global.lastclicked this.number;
                
_global.projektid2 _global.ProjekteArray[this.number][0];
                
                }
            };
            
// Set Alpha of Link to 50 Babybaby!
            
cont._alpha 50;
            
cont.onRollOver = function() { 
            
// Fade me in Baby!
                
this.fadinout(0,100,2,1);
            };
            
cont.onRollOut = function() { 
            
// Fade out if allowed!
                
if(_global.lastclicked != this.number) {
                
this.fadinout(1,50,2,1);
                }
            };
        }         
}
// Diese Funktion Baut die Buttons fuer die Einzelnen Galerie- Bilder zusammen
// Und erstellt Movie Clips mit einer onRelease eigenschaft, die dann zur Laderoutine
// uebergehen.
// var projektid
function loadPictureData(projektid) {
    
                        
// Hauptbild funktion
        
createEmptyMovieClip("hauptbild"+projektidthis.getNextHighestDepth());
        
_root["hauptbild"+projektid]._y0;
        
_root["hauptbild"+projektid]._x241;
        
_root["hauptbild"+projektid].loadMovie(_global.ProjekteArray[projektid][3]);
    
        
// Zaehle wieviele Bilder wir insgesamt haben.
        
gallery_dis _global.BilderArray.length;
        
// Stelle X Counter auf 0 um die horizontale Position zu fixieren
        
241;
        
0;
        for (var 
s=0s<gallery_diss++) {  
            
// Zeige nur die Bilder an, die der richtigen Projekt ID zugeordnet sind.
            
if (_global.BilderArray[s][0eq projektid) {
                
createEmptyMovieClip("bildnavcont"+projektidthis.getNextHighestDepth());
                
_root["bildnavcont"+projektid].createEmptyMovieClip("bildcont"+sthis.getNextHighestDepth());
                
// Definiere die Variablen für den Rechteck Platzhalter
                
                
var rw:Number 114;
                var 
rh:Number 84;
                var 
rbgColor_normal:Number 0xFFFFFF;
                
_root["bildnavcont"+projektid]["bildcont"+s]._y 250;
                
_root["bildnavcont"+projektid]["bildcont"+s]._x + (* (112+11));
                
_root["bildnavcont"+projektid]["bildcont"+s].beginFill(rbgColor_normal);
                
_root["bildnavcont"+projektid]["bildcont"+s].lineTo(rw0);
                
_root["bildnavcont"+projektid]["bildcont"+s].lineTo(rwrh);
                
_root["bildnavcont"+projektid]["bildcont"+s].lineTo(0rh);
                
_root["bildnavcont"+projektid]["bildcont"+s].lineTo(00);
                
                
// Button Erstellung und Verweiss auf Datenfunktionen erstellen
                
this["bildnavcont"+projektid]["bildcont"+s].number s;
                
                
// im Zusammenhang mit der unterem auskommentieren befehlt geht alles nur ohne preload eben.
                //_root["bildnavcont"+projektid]["bildcont"+s].createEmptyMovieClip("bildcont2"+s, this.getNextHighestDepth());
                
                // ab hier fängt das problem an
                  
var clipLoader = new MovieClipLoader();
                    
                  var 
listener:Object = new Object();
            
                  
clipLoader.addListener(listener);
                  
                  
listener.onLoadInit = function(obj) {
                      
trace("loading");
                  };
                   
                  
_root["bildnavcont"+projektid]["bildcont"+s].createEmptyMovieClip("bildcont2"+sthis.getNextHighestDepth());
                  
clipLoader.loadClip(_global.BilderArray[s][2], con);
                   
                
//Diese Auskommentiere Funktion geht!
                //_root["bildnavcont"+projektid]["bildcont"+s]["bildcont2"+s].loadMovie(_global.BilderArray[s][2]);
                
_root["bildnavcont"+projektid]["bildcont"+s]["bildcont2"+s]._y 1;
                
_root["bildnavcont"+projektid]["bildcont"+s]["bildcont2"+s]._x 1;
                
_root["bildnavcont"+projektid]["bildcont"+s].onRollOver = function() { 
                                
this._alpha 100;
                               };
                
_root["bildnavcont"+projektid]["bildcont"+s].onRollOut = function() { 
                                
this._alpha 60;
                            };
                
_root["bildnavcont"+projektid]["bildcont"+s]._alpha 60;
                
                
// Button Erstellung
                
_root["bildnavcont"+projektid]["bildcont"+s].onRelease = function() { 
                    
getURL("http://www.google.com""_blank");

                };
                

                
                
y+1;
            }
        }

soklai ist offline   Mit Zitat antworten
Alt 30-05-2006, 16:29   #2 (permalink)
agedoubleju
Gast
 
Beiträge: n/a
Zitat:
statt den loadmovie befehl zu nehmen es so hinwursteln, das diese bilder preloaded werden und sobald sie fertig geladen sind schön einfaden.
Ohne mir jetzt diese "Codewüste" anzutun: der loadMovie-Befehl ist bei einfachen Preloadern Teil des Konzeptes.

Wenn du allerdings mehrere Bilder oder Filme hintereinander laden willst und das Laden überwacht werden muss, solltest du auf die MovieClipLoader-Klasse zurückgreifen. Schau mal in die Flash-Hilfe.
  Mit Zitat antworten
Alt 30-05-2006, 16:38   #3 (permalink)
Querdenker
 
Registriert seit: Aug 2003
Ort: Berlin
Beiträge: 32
hmm habe nun folgende funktion programmiert..

PHP-Code:
function preload(urlu) {
                var 
mcl:MovieClipLoader = new MovieClipLoader();
                var 
mclL:Object = new Object();
                
mclL.onLoadProgress = function(target,loaded,total) {
            
// brauche ich noch nicht
                
}
                
mclL.onLoadInit = function() {
    
// brauche ich noch nicht
                
}
                
mcl.addListener(mclL);
                
mcl.loadClip(url,this);

funktioniert nur leider nicht, rufe die funktion folgendermassen auf...


_root["bildnavcont"+projektid]["bildcont"+s]["bildcont2"+s].preload(_global.BilderArray[s][2], s);
soklai ist offline   Mit Zitat antworten
Alt 30-05-2006, 16:51   #4 (permalink)
agedoubleju
Gast
 
Beiträge: n/a
Zitat:
mcl.loadClip(url,this);
Das "this" zeigt auf die aktuelle Zeitleiste. Du willst doch aber in einen anderen MC laden, oder?
  Mit Zitat antworten
Alt 30-05-2006, 16:53   #5 (permalink)
Querdenker
 
Registriert seit: Aug 2003
Ort: Berlin
Beiträge: 32
na in diesen hier :

_root["bildnavcont"+projektid]["bildcont"+s]["bildcont2"+s]

aber ich rufe die funktion ja richtig auf...
soklai ist offline   Mit Zitat antworten
Alt 30-05-2006, 16:58   #6 (permalink)
agedoubleju
Gast
 
Beiträge: n/a
Was zeigt dir ein trace("this="+this) und ein trace("url="+url) hinter dem loadClip-Befehl denn im Testmodus an?
  Mit Zitat antworten
Alt 30-05-2006, 17:01   #7 (permalink)
................
 
Benutzerbild von Der Frager
 
Registriert seit: Jun 2004
Beiträge: 15.890
Zitat:
Zitat von soklai
aber ich rufe die funktion ja richtig auf...
Ist das so?
PHP-Code:
function preload(urlziel) { 
                var 
mcl:MovieClipLoader = new MovieClipLoader(); 
                var 
mclL:Object = new Object(); 
                
mclL.onLoadProgress = function(target,loaded,total) { 
            
// brauche ich noch nicht 
                

                
mclL.onLoadInit = function() { 
    
// brauche ich noch nicht 
                

                
mcl.addListener(mclL); 
                
mcl.loadClip(url,ziel); 
}  
preload(BilderArray[s][2], _root["bildnavcont"+projektid]["bildcont"+s]["bildcont2"+s]); 
__________________

ternärer Konditionaloperator

+++ Bitte keine Privat-Nachrichten bezüglich Flashfragen! +++
Der Frager ist offline   Mit Zitat antworten
Alt 30-05-2006, 17:03   #8 (permalink)
Querdenker
 
Registriert seit: Aug 2003
Ort: Berlin
Beiträge: 32
hmm...

geht trotzdem nicht, das bild wird einfach nicht geladen...
soklai 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:38 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele