Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 19-02-2005, 20:18   #1 (permalink)
Blitzuser
 
Registriert seit: Feb 2004
Beiträge: 468
Function in einem Loop

Hallo, ich habe folgenden Code...
Klappt auch fast alles super, mein problem:
wenn ich auf eins der images klicke oeffent sich der image holder,
aber er versucht dann immer images/undefined zu laden...

Was wohl bedeutet das im for loop das i nicht bei der function ankommt:

[PHP]myXML = new XML();
myXML.ignoreWhite=true;
myXML.onLoad = doXML;
myXML.load("tahneeXML.xml");


function doXML(){
items = myXML.firstChild.childNodes;

//trace(myXML.firstChild.childNodes.length);
for( i = 0; i<myXML.firstChild.childNodes.length;i++){
_root.attachMovie("image","image"+i,i);

_root["image"+i].onPress = function(){
bigIMG._visible = false;
bigIMG._visible = true;
trace(i);
_root.bigIMG.loadMovie(myXML.firstChild.childNodes[i].attributes["limage"]);
}

var track = i;
// trace(track);
if (track>=4){
_root["image"+i]._x = 140*i;
_root["image"+i]._x += -590.5;
_root["image"+i]._y = 320.5;
}else {
_root["image"+i]._x = 125*i;
_root["image"+i]._x += -30.5;
_root["image"+i]._y = 120.5;
}
_root["image"+i].imgClip.loadMovie(myXML.firstChild.childNodes[i].attributes["thumbnail"]);
_root["image"+i].id.text = myXML.firstChild.childNodes[i].attributes["id"];
_root["image"+i].title.text = myXML.firstChild.childNodes[i].attributes["title"];
_root["image"+i].description.text = myXML.firstChild.childNodes[i].attributes["description"];
//trace(myXML.firstChild.childNodes[i].attributes["limage"]);

}
}

bigIMG.onLoad = function(){
this._visible = false;
}
bigIMG.onPress = function(){
this._visible = false;
}

[PHP]

Danke
nxfxcom ist offline   Mit Zitat antworten
Alt 20-02-2005, 01:09   #2 (permalink)
agedoubleju
Gast
 
Beiträge: n/a
Wenn du in einer Schleife MC- oder Button-Events setzt, "merkt" sich der MC/Button den Schleifenzählerwert nicht. Nach der Schleife steht der nicht mehr zur Verfügung, das bedeutet also, dass sich das Objekt den Wert merken muss, z.B.:
ActionScript:
  1. ...
  2.  _root["image"+i].onPress = function(){
  3.    _root["image"+i].ID = i;
  4.    ...
  5.     _root.bigIMG.loadMovie(myXML.firstChild.childNodes[_root["image"+i].ID].attributes["limage"]);
  6. }
  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 13:28 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele