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(io, fa, st, br) {
var mc = this;
var i = 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=0; i<ProjekteTotal; i++) {
ProjekteArray[i] = [[i],[xmlNode.childNodes[i].attributes.titel],[xmlNode.childNodes[i].attributes.ort],[xmlNode.childNodes[i].attributes.hauptbild]];
currentMAX = k + xmlNode.childNodes[i].childNodes[1].childNodes.length;
// Alle Bilder aus dem momentan Durchlaufendem Projekt beziehen
for (k=0; k<xmlNode.childNodes[i].childNodes[1].childNodes.length; k++) {
BilderArray[h] = [[i],[xmlNode.childNodes[i].childNodes[1].childNodes[k].attributes.name],[xmlNode.childNodes[i].childNodes[1].childNodes[k].attributes.pic]];
h = 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=0; s<projekte_dis; s++) {
var w:Number = 100;
var h:Number = 20;
var bgColor_normal:Number = 0x911201;
var bgColor_hover:Number = 0x911201;
var cont:MovieClip = createEmptyMovieClip("container"+s, this.getNextHighestDepth());
cont.beginFill(bgColor_normal);
cont.lineTo(w, 0);
cont.lineTo(w, h);
cont.lineTo(0, h);
cont.lineTo(0, 0);
cont._x = 38;
cont._y = 338 - s*(h+1);
cont.createTextField("teext"+s, s, 10, 1, 0, this.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"+projektid, this.getNextHighestDepth());
_root["hauptbild"+projektid]._y= 0;
_root["hauptbild"+projektid]._x= 241;
_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
x = 241;
y = 0;
for (var s=0; s<gallery_dis; s++) {
// Zeige nur die Bilder an, die der richtigen Projekt ID zugeordnet sind.
if (_global.BilderArray[s][0] eq projektid) {
createEmptyMovieClip("bildnavcont"+projektid, this.getNextHighestDepth());
_root["bildnavcont"+projektid].createEmptyMovieClip("bildcont"+s, this.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 = x + (y * (112+11));
_root["bildnavcont"+projektid]["bildcont"+s].beginFill(rbgColor_normal);
_root["bildnavcont"+projektid]["bildcont"+s].lineTo(rw, 0);
_root["bildnavcont"+projektid]["bildcont"+s].lineTo(rw, rh);
_root["bildnavcont"+projektid]["bildcont"+s].lineTo(0, rh);
_root["bildnavcont"+projektid]["bildcont"+s].lineTo(0, 0);
// 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"+s, this.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 = y+1;
}
}
}