Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 18-03-2005, 14:24   #1 (permalink)
class public{}
 
Benutzerbild von public
 
Registriert seit: Feb 2004
Ort: dessau
Beiträge: 1.406
Slide Gallerie

Guten Tag...
Ich habe ein kleines Problem mit meiner Gallerie.
Die URL s zu den Bildern werden via XML geladen un d in einem Array (dURL) gespeichert. Nun mein Problem, beim ersten laden (automatisch) kann ich nicht auf das Array dURL zugreifen, sondern ich muss die Bild URL als String angeben.

ActionScript:
  1. //*******************************************
  2. // GENAU DAS MEINE ICH, ES MUESSTE HEISSEN  *
  3. // loadCont(dURL[0],cont_mc,loader_mc);     *
  4. // GEHT ABER NICHT                          *
  5. //*******************************************
  6. loadCont("bilder/01.jpg", cont_mc, loader_mc);

wie bekomme ich es nun hin das ich auf das Array zugreifen kann.
Wenn die Methode loadCont in einem Event Handler liegt geht es, aber es soll ja das erste Foto automatisch geladen werden.
Ich hoffe ihr habt mich verstanden.

download

Hier der gesamte Code

ActionScript:
  1. stop();
  2. System.useCodepage = true;
  3. MovieClip.prototype.loadCont = function(pURL, pCont, pLoader) {
  4.     _global.end = false;
  5.     pCont._alpha = 0;
  6.     pCont.loadMovie(pURL);
  7.     pLoader._visible = true;
  8.     rahmen_mc._visible = true;
  9.     this.onEnterFrame = function() {
  10.         var geladen = pCont.getBytesLoaded();
  11.         var gesamt = pCont.getBytesTotal();
  12.         var prozent = geladen/gesamt*100;
  13.         //trace(prozent);
  14.         pLoader._width = prozent;
  15.         if (prozent == 100) {
  16.             var breite = pCont._width;
  17.             var hohe = pCont._height+head_mc._height;
  18.             pLoader._visible = false;
  19.             //pCont._visible = true;
  20.             rahmen_mc._visible = false;
  21.             //setLayout();
  22.             body_mc.slideScale(breite, hohe, pCont, 4, 10);
  23.             delete this.onEnterFrame;
  24.         }
  25.     };
  26. };
  27. /*
  28. slideScale
  29. */
  30. MovieClip.prototype.slideScale = function(pW, pH, pCont, pSteps, pSpeedAlpha) {
  31.     _global.end = false;
  32.     this.onEnterFrame = function() {
  33.         var diffX = pW-this._width;
  34.         var diffY = pH-this._height;
  35.         this._width += diffX/pSteps;
  36.         this._height += diffY/pSteps;
  37.         setLayout();
  38.         if (Math.round(this._height) == pH && Math.round(this._width) == pW) {
  39.             this._width = pW;
  40.             this._height = pH;
  41.             setLayout();
  42.             pCont._alpha += pSpeedAlpha;
  43.             if (pCont._alpha>=100) {
  44.                 pCont._alpha = 100;
  45.                 _global.end = true;
  46.                 delete this.onEnterFrame;
  47.             }
  48.         }
  49.     };
  50. };
  51. /*
  52. setLayout
  53. */
  54. MovieClip.prototype.setLayout = function() {
  55.     // body_mc
  56.     //this.body_mc._width = this.cont_mc._width;
  57.     //this.body_mc._height = this.cont_mc._height+this.head_mc._height;
  58.     // cont_mc
  59.     cont_mc._x = body_mc._x-body_mc._width/2;
  60.     cont_mc._y = body_mc._y-body_mc._height/2+this.head_mc._height;
  61.     // head_mc
  62.     head_mc._width = body_mc._width;
  63.     head_mc._y = body_mc._y-body_mc._height/2+head_mc._height/2;
  64.     // rahmen_mc
  65.     rahmen_mc._x = body_mc._x-rahmen_mc._width/2;
  66.     rahmen_mc._y = body_mc._y;
  67.     rahmen_mc._visible = false;
  68.     // loader_mc
  69.     loader_mc._x = body_mc._x-rahmen_mc._width/2;
  70.     loader_mc._y = body_mc._y;
  71.     loader_mc._width = 0;
  72.     loader_mc._visible = false;
  73.     // Buttons
  74.     next_btn._x = head_mc._x+head_mc._width/2-next_btn._width-10;
  75.     next_btn._y = head_mc._y-head_mc._height/2+next_btn._height-8.5;
  76.     prev_btn._x = head_mc._x+head_mc._width/2-prev_btn._width*2-20;
  77.     prev_btn._y = head_mc._y-head_mc._height/2+prev_btn._height-8.5;
  78. };
  79. //
  80. //
  81. //
  82. /*
  83. Arrays
  84. */
  85. var dURL = new Array();
  86. var dText = new Array();
  87. var daten = new XML();
  88. /*
  89. Variablen
  90. */
  91. var counter = 0;
  92. _global.end = true;
  93. _global.starter;
  94. /*
  95. XML auslesen
  96. */
  97. daten.ignoreWhite = true;
  98. daten.load("list.xml");
  99. daten.onLoad = function(ok) {
  100.     if (ok) {
  101.         for (var i = 0; i<this.firstChild.childNodes.length; i++) {
  102.             dURL.push(this.firstChild.childNodes[i].attributes.url);
  103.             dText.push(this.firstChild.childNodes[i].attributes.text);
  104.         }
  105.        
  106.        
  107.        
  108.            
  109.        
  110.     }
  111. };
  112. body_mc._width = 300;
  113. body_mc._height = 400;
  114. //
  115. setLayout();
  116. //*******************************************
  117. // GENAU DAS MEINE ICH, ES MUESSTE HEISSEN  *
  118. // loadCont(dURL[0],cont_mc,loader_mc);     *
  119. // GEHT ABER NICHT                          *
  120. //*******************************************
  121. loadCont("bilder/01.jpg", cont_mc, loader_mc);
  122. //
  123. //
  124. //
  125. this.next_btn.onRelease = function() {
  126.     if (counter<dURL.length-1 && _global.end == true) {
  127.         counter++;
  128.         trace(dURL[counter]);
  129.         loadCont(dURL[counter], cont_mc, loader_mc);
  130.     }
  131. };
  132. this.prev_btn.onRelease = function() {
  133.     if (counter>0 && _global.end == true) {
  134.         counter--;
  135.         loadCont(dURL[counter], cont_mc, loader_mc);
  136.     }
  137. };


Ciao Public
public ist offline   Mit Zitat antworten
Alt 18-03-2005, 14:37   #2 (permalink)
 
Registriert seit: Dec 2003
Beiträge: 202
so mal auf die schnelle, würde ich sagen du versuchst auf dURL zuzugreifen bevor dein xml überhaupt geladen wurde.

probier doch folgendes:

PHP-Code:
daten.onLoad = function(ok) { 
 if (
ok) { 
  for (var 
0i<this.firstChild.childNodes.lengthi++) { 
   
dURL.push(this.firstChild.childNodes[i].attributes.url); 
   
dText.push(this.firstChild.childNodes[i].attributes.text); 
  } 
 
loadCont(dURL[0], cont_mcloader_mc); 
 } 
}; 
und lass das dafür weg:
PHP-Code:
loadCont("bilder/01.jpg"cont_mcloader_mc); 
bryan.fury ist offline   Mit Zitat antworten
Alt 18-03-2005, 14:47   #3 (permalink)
class public{}
 
Benutzerbild von public
 
Registriert seit: Feb 2004
Ort: dessau
Beiträge: 1.406
Das hab ich auch schon probiert, geht aber auch nicht.

Ciao Public
public ist offline   Mit Zitat antworten
Alt 18-03-2005, 14:54   #4 (permalink)
 
Registriert seit: Dec 2003
Beiträge: 202
sorry,

PHP-Code:
var scope this;
daten.onLoad = function(ok) { 
if (
ok) { 
**for (var 
0i<this.firstChild.childNodes.lengthi++) { 
***
scope.dURL.push(this.firstChild.childNodes[i].attributes.url); 
***
scope.dText.push(this.firstChild.childNodes[i].attributes.text); 
**} 
scope.loadCont(scope.dURL[0], scope.cont_mcscope.loader_mc); 

}; 
bin mir aber nicht sicher ob "this" bei einem XML object geht?

ansonsten:

PHP-Code:
var scope this;
daten.onLoad = function(ok) { 
if (
ok) { 
**
scope.startShow();

}; 

function 
startShow () {
for (var 
0idaten.firstChild.childNodes.lengthi++) { 
***
dURL.push(daten.firstChild.childNodes[i].attributes.url); 
***
dText.push(daten.firstChild.childNodes[i].attributes.text); 
**} 
loadCont(dURL[0], cont_mcloader_mc);


weis nicht woher die **** kommen? die müssen natürlich weg!
bryan.fury ist offline   Mit Zitat antworten
Alt 18-03-2005, 15:39   #5 (permalink)
class public{}
 
Benutzerbild von public
 
Registriert seit: Feb 2004
Ort: dessau
Beiträge: 1.406
Geht leider auch, er läd zwar das bild aber der slidevorgang geht nicht mehr.


Ciao Public
public ist offline   Mit Zitat antworten
Alt 18-03-2005, 15:47   #6 (permalink)
class public{}
 
Benutzerbild von public
 
Registriert seit: Feb 2004
Ort: dessau
Beiträge: 1.406
Am besten ihr ladet es euch mal runter, und guckt dann mal. Weil sich Flash bei der Sache igendwie total unlogisch verhält. Weil die Antworten die bisher waren hatte ich schon alle ausprobiert bevor ich hier gepostet habe, aber trotzdem DANKE.


Cioa Public
public ist offline   Mit Zitat antworten
Alt 18-03-2005, 16:08   #7 (permalink)
 
Registriert seit: Dec 2003
Beiträge: 202
funktioniert eh so wie ich gesagt habe:

PHP-Code:
stop();
System.useCodepage true;
MovieClip.prototype.loadCont = function(pURLpContpLoader) {
    
_global.end false;
    
pCont._alpha 0;
    
pCont.loadMovie(pURL);
    
pLoader._visible true;
    
rahmen_mc._visible true;
    
this.onEnterFrame = function() {
        var 
geladen pCont.getBytesLoaded();
        var 
gesamt pCont.getBytesTotal();
        var 
prozent geladen/gesamt*100;
        
//trace(prozent);
        
pLoader._width prozent;
        if (
prozent == 100 && gesamt 10) {
            var 
breite pCont._width;
            var 
hohe pCont._height+head_mc._height;
            
pLoader._visible false;
            
//pCont._visible = true;
            
rahmen_mc._visible false;
            
//setLayout();
            
body_mc.slideScale(breitehohepCont410);
            
delete this.onEnterFrame;
        }
    };
};
/*
slideScale
*/
MovieClip.prototype.slideScale = function(pWpHpContpStepspSpeedAlpha) {
    
_global.end false;
    
this.onEnterFrame = function() {
        var 
diffX pW-this._width;
        var 
diffY pH-this._height;
        
this._width += diffX/pSteps;
        
this._height += diffY/pSteps;
        
setLayout();
        if (
Math.round(this._height) == pH && Math.round(this._width) == pW) {
            
this._width pW;
            
this._height pH;
            
setLayout();
            
pCont._alpha += pSpeedAlpha;
            if (
pCont._alpha>=100) {
                
pCont._alpha 100;
                
_global.end true;
                
delete this.onEnterFrame;
            }
        }
    };
};
/*
setLayout
*/
MovieClip.prototype.setLayout = function() {
    
// body_mc
    //this.body_mc._width = this.cont_mc._width;
    //this.body_mc._height = this.cont_mc._height+this.head_mc._height;
    // cont_mc
    
cont_mc._x body_mc._x-body_mc._width/2;
    
cont_mc._y body_mc._y-body_mc._height/2+this.head_mc._height;
    
// head_mc
    
head_mc._width body_mc._width;
    
head_mc._y body_mc._y-body_mc._height/2+head_mc._height/2;
    
// rahmen_mc 
    
rahmen_mc._x body_mc._x-rahmen_mc._width/2;
    
rahmen_mc._y body_mc._y;
    
rahmen_mc._visible false;
    
// loader_mc
    
loader_mc._x body_mc._x-rahmen_mc._width/2;
    
loader_mc._y body_mc._y;
    
loader_mc._width 0;
    
loader_mc._visible false;
    
// Buttons
    
next_btn._x head_mc._x+head_mc._width/2-next_btn._width-10;
    
next_btn._y head_mc._y-head_mc._height/2+next_btn._height-8.5;
    
prev_btn._x head_mc._x+head_mc._width/2-prev_btn._width*2-20;
    
prev_btn._y head_mc._y-head_mc._height/2+prev_btn._height-8.5;
};
//
//
//
/*
Arrays
*/
var dURL = new Array();
var 
dText = new Array();
var 
daten = new XML();
/*
Variablen
*/
var counter 0;
_global.end true;
_global.starter;
/*
XML auslesen
*/
daten.ignoreWhite true;
daten.load("list.xml");
var 
scope this;
daten.onLoad = function(ok) {
    if (
ok) {
        
scope.startShow ()
    }
};
body_mc._width 300;
body_mc._height 400;
//
setLayout();
//*******************************************
// GENAU DAS MEINE ICH, ES MUESSTE HEISSEN  *
// loadCont(dURL[0],cont_mc,loader_mc);     *
// GEHT ABER NICHT                          *
//*******************************************
//loadCont("bilder/01.jpg", cont_mc, loader_mc);
function startShow () {
    for (var 
0idaten.firstChild.childNodes.lengthi++) { 
        
dURL.push(daten.firstChild.childNodes[i].attributes.url); 
        
dText.push(daten.firstChild.childNodes[i].attributes.text); 
    } 
    
loadCont(dURL[0],cont_mc,loader_mc);
}
//
//
//
this.next_btn.onRelease = function() {
    if (
counter<dURL.length-&& _global.end == true) {
        
counter++;
        
trace(dURL[counter]);
        
loadCont(dURL[counter], cont_mcloader_mc);
    }
};
this.prev_btn.onRelease = function() {
    if (
counter>&& _global.end == true) {
        
counter--;
        
loadCont(dURL[counter], cont_mcloader_mc);
    }
}; 
bryan.fury ist offline   Mit Zitat antworten
Alt 18-03-2005, 16:28   #8 (permalink)
class public{}
 
Benutzerbild von public
 
Registriert seit: Feb 2004
Ort: dessau
Beiträge: 1.406
Hey ein große DANKE.
Jetzt gehts.

Ciao Public
public ist offline   Mit Zitat antworten
Alt 18-03-2005, 16:39   #9 (permalink)
 
Registriert seit: Dec 2003
Beiträge: 202
PHP-Code:
if (prozent == 100 && gesamt 10
das hat gefehlt.
es dauert nämlich mindest ein frame bis er die info über das zu ladende file erhält.
sonst ist nämlich pCont.getBytesTotal() == 0 und damit prozent == 100 bevor das bild geladen wird.
bryan.fury 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:40 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele