Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 08-02-2006, 10:16   #1 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 134
RollOver Event bei dyn. generierten mc

Hallo!

Ich habe ein Problem mit folgendem Code:

Code:
lv = new LoadVars();
//onLoad Handler wird ausgeführt wenn die daten ankommen! 
lv.onLoad = function(sucess) 
{
     if (sucess) 
     {
           ...
           ...
           var Names:Array = new Array();
           for (var j = 0; j<firstA.length; j++) 
           {
                 _root.attachMovie("Ball", "auto"+j, j);
                 _root["clip_obj"+j] = new AutoObjekt(_root["auto"+j], tmp[1], tmp[2], tmp[3], parseInt(EZ), tmp[5], tmp[6], tmp[7], tmp[8], tmp[9]);
	
                 Names.push(_root["clip_obj"+j].Name);

	         _root["auto"+j].onRollOver = function()
	         {
	              _root.createEmptyMovieClip("pane",j);
	              _root.pane.attachMovie("Panel", "pane", j);
                      _root.pane.pane._x = this._x;
	              _root.pane.pane._y = this._y;
	              trace(Names[19]+ " " +j);
				
	              //trace(_root["clip_obj"+j].Preis);
	              //_root.pane.pane.auto_name = _root["clip_obj"+j].Name;
	              //_root.pane.pane.gotoAndPlay(1);
	          }                                  

            }
       }
}
Mit dem Aufruf _root["clip_obj"+j] = new AutoObjekt wird dem mc eine AutoKlasse zugeordnet. Demnach könnte man den Preis eines bestimmten Autos mit _root.clip_objx.Preis abfragen.
Auf diese Information kann ich auch zugreifen, aber komischerweise nur außerhalb der RollOver Funktion. Wenn ich mir da die Info tracen möchte kommt immer undefined raus. Weiß vielleicht jemand wo mein Denkfehler liegt?

Vielen Dank schon mal.

Gruß,

Wassim
Wassim ist offline   Mit Zitat antworten
Alt 08-02-2006, 10:29   #2 (permalink)
°.oO°O.o°.oO.o°O
 
Benutzerbild von bamboocha
 
Registriert seit: Jun 2005
Ort: CH
Beiträge: 1.490
Ja, weiss ich! Du durchläufst ja ne Schleife und weist die Daten zu. Das Problem ist, dass der Button bei onRollOver die Daten von "_root["auto"+j]" holen will. Da aber j in der Schleife erhöht wurde und die Buttons erst nach der Initialisierung (und somit dem Schleifendurchlauf) sichtbar sind, ist j = firstA.length (das letzte mal wird es doch noch erhöht, obwohl < firstA.length erfüllt wäre). Tja, nun gibt es aber kein Objekt, welches als j die Anzahl Elemente in firstA hat! Umgehe das ganze, indem du entweder dem jeweiligen MC eine id verpasst, der du den j-Wert zuweist oder aber frage nicht nach _root sondern verwende nur "this"! This bezieht sich ja auf den entsprechenden MC!
Also, entweder:
ActionScript:
  1. lv = new LoadVars();
  2. //onLoad Handler wird ausgeführt wenn die daten ankommen!
  3. lv.onLoad = function(sucess)
  4. {
  5.      if (sucess)
  6.      {
  7.            ...
  8.            ...
  9.            var Names:Array = new Array();
  10.            for (var j = 0; j<firstA.length; j++)
  11.            {
  12.                  _root.attachMovie("Ball", "auto"+j, j);
  13.                  _root["clip_obj"+j] = new AutoObjekt(_root["auto"+j], tmp[1], tmp[2], tmp[3], parseInt(EZ), tmp[5], tmp[6], tmp[7], tmp[8], tmp[9]);
  14.    
  15.                  Names.push(_root["clip_obj"+j].Name);
  16.                       _root["auto"+j].id = j;
  17.              _root["auto"+j].onRollOver = function()
  18.              {
  19.                   _root.createEmptyMovieClip("pane",j);
  20.                   _root.pane.attachMovie("Panel", "pane", j);
  21.                       _root.pane.pane._x = this._x;
  22.                   _root.pane.pane._y = this._y;
  23.                   trace(Names[19]+ " " +j);
  24.                
  25.                   //trace(_root["clip_obj"+this.id].Preis);
  26.                   //_root.pane.pane.auto_name = _root["clip_obj"+this.id].Name;
  27.                   //_root.pane.pane.gotoAndPlay(1);
  28.               }                                 
  29.  
  30.             }
  31.        }
  32. }
oder aber:
ActionScript:
  1. lv = new LoadVars();
  2. //onLoad Handler wird ausgeführt wenn die daten ankommen!
  3. lv.onLoad = function(sucess)
  4. {
  5.      if (sucess)
  6.      {
  7.            ...
  8.            ...
  9.            var Names:Array = new Array();
  10.            for (var j = 0; j<firstA.length; j++)
  11.            {
  12.                  _root.attachMovie("Ball", "auto"+j, j);
  13.                  _root["clip_obj"+j] = new AutoObjekt(_root["auto"+j], tmp[1], tmp[2], tmp[3], parseInt(EZ), tmp[5], tmp[6], tmp[7], tmp[8], tmp[9]);
  14.    
  15.                  Names.push(_root["clip_obj"+j].Name);
  16.  
  17.              _root["auto"+j].onRollOver = function()
  18.              {
  19.                   _root.createEmptyMovieClip("pane",j);
  20.                   _root.pane.attachMovie("Panel", "pane", j);
  21.                            _root.pane.pane._x = this._x;
  22.                   _root.pane.pane._y = this._y;
  23.                   trace(Names[19]+ " " +j);
  24.                
  25.                   //trace(this.Preis);
  26.                   //_root.pane.pane.auto_name = this.Name;
  27.                   //_root.pane.pane.gotoAndPlay(1);
  28.               }                                 
  29.  
  30.             }
  31.        }
  32. }
__________________
There is no way to happiness, happiness is the way! - Buddha
bamboocha ist offline   Mit Zitat antworten
Alt 08-02-2006, 11:18   #3 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 134
Vielen vielen Dank!
Daran lag es. Und wieder was gelernt

Gruß,

Wassim
Wassim 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