FOr schleife schluckt ersten datensatz

Gerri84

Mitglied
So wieder mal ich ;)

lade ein xml file um die news einzulesen... problem er überschreibt oder löscht mir den ersten datensatz der platz bleibt reserviert und wenn ich mir die werte mit trace ausgeben läßt sind auch alle da !

hat jemand einen tipp für mich ?

PHP:
var xml_news:XML = new XML();
xml_news.ignoreWhite = true;

xml_news.onLoad = function()
	{
		var numOfNews:Number = 0;
		var nodes_news = this.firstChild.childNodes;
		numOfNews = nodes_news.length;
		
		trace(numOfNews);						
		for(var i=0;i<numOfNews;i++)
			{	 
				_root.createEmptyMovieClip("news_proto_mc", 300);
				
				_root.news_proto_mc.duplicateMovieClip(["news_mc"+i], 300+i);

				_root.news_proto_mc.removeMovieClip();
				
				_root["news_mc"+i].createTextField("date_txt", 310, 0, 0, 100, 20);
				
				_root["news_mc"+i].date_txt.setNewTextFormat(news_date_fmt); 
				_root["news_mc"+i].date_txt.wordWrap = true;
				_root["news_mc"+i].date_txt.multiline = true;
				_root["news_mc"+i].date_txt.html = true;
				_root["news_mc"+i].date_txt.selectable = false;
				_root["news_mc"+i].date_txt.border = false;
				_root["news_mc"+i].date_txt.antiAliasType = true;
				_root["news_mc"+i].date_txt._y = 20;
				_root["news_mc"+i].date_txt._x = 0;
				
				_root["news_mc"+i].date_txt.htmlText = this.firstChild.childNodes[i].attributes.date;
				
				_root["news_mc"+i].createTextField("headline_txt", 320, 0, 0, 200, 20);	
				
				_root["news_mc"+i].headline_txt.setNewTextFormat(news_head_fmt); 
				_root["news_mc"+i].headline_txt.wordWrap = true;
				_root["news_mc"+i].headline_txt.multiline = true;
				_root["news_mc"+i].headline_txt.html = true;
				_root["news_mc"+i].headline_txt.selectable = false;
				_root["news_mc"+i].headline_txt.border = false;
				_root["news_mc"+i].headline_txt.antiAliasType = true;
				_root["news_mc"+i].headline_txt._y = 20;
				_root["news_mc"+i].headline_txt._x = 100;
				
				_root["news_mc"+i].headline_txt.htmlText = this.firstChild.childNodes[i].attributes.headline;
				
				_root["news_mc"+i].createTextField("news_txt", 330, 0, 0, 200, 150);
				
				_root["news_mc"+i].news_txt.setNewTextFormat(news_fmt); 
				_root["news_mc"+i].news_txt.wordWrap = true;
				_root["news_mc"+i].news_txt.multiline = true;
				_root["news_mc"+i].news_txt.html = true;
				_root["news_mc"+i].news_txt.selectable = false;
				_root["news_mc"+i].news_txt.border = false;
				_root["news_mc"+i].news_txt.antiAliasType = true;
				_root["news_mc"+i].news_txt._y = 40;
				_root["news_mc"+i].news_txt._x = 100;
				
				_root["news_mc"+i].news_txt.htmlText = this.firstChild.childNodes[i].childNodes;
				
				_root["news_mc"+i].news_txt.setLimitedText (_root["news_mc"+i].news_txt.text, 190);
				
				_root["news_mc"+i].createEmptyMovieClip("read_more_mc", 340)
				_root["news_mc"+i].read_more_mc._y = 175;
				_root["news_mc"+i].read_more_mc._x = 100;
				
				_root["news_mc"+i].read_more_mc.createTextField("readmore_txt", 350, 0, 0, 200, 20);
					
				_root["news_mc"+i].read_more_mc.readmore_txt.setNewTextFormat(news_fmt); 
				_root["news_mc"+i].read_more_mc.readmore_txt.wordWrap = true;
				_root["news_mc"+i].read_more_mc.readmore_txt.multiline = true;
				_root["news_mc"+i].read_more_mc.readmore_txt.html = true;
				_root["news_mc"+i].read_more_mc.readmore_txt.selectable = false;
				_root["news_mc"+i].read_more_mc.readmore_txt.border = false;
				_root["news_mc"+i].read_more_mc.readmore_txt.antiAliasType = true;
				_root["news_mc"+i].read_more_mc.readmore_txt._y = 0;
				_root["news_mc"+i].read_more_mc.readmore_txt._x = 0;
				
				_root["news_mc"+i].read_more_mc.readmore_txt.htmlText = "[...read more]";
				
				_root["news_mc"+i]._y = 50+(190*i);
				_root["news_mc"+i]._x = breite-320;
				
				_root["news_mc"+i].read_more_mc.onRelease = function()
						{
						
						}
			}
	}

xml_news.load("news.xml");
 
Hi,

kannst Du bitte mal Deine .fla und die dazugehörige XML-Datei posten? Auf den ersten Blick kann ich nämlich keinen Fehler entdecken.

Gruß
.
 
Bitte schön



PHP:
<?xml version="1.0" encoding="utf-8"?>

<news>

	<newscontent date="21.July 2007" headline="SS HOLDING NEWS" link="http://www.orf.at">THE WORLD F I R ST CLIMATE CONTROLLED Championship Golf Course. It Is A  TOURISM ATTRACTION And A LANDMARK And Will Be A LEADING GOLF DESTINATION In The Future.This WORLD UNIQUE DEVELOPMENT Was Presented In Abu Dhabi The Capital Of The UAE To The Public And All Golf Enthusiasts!
	</newscontent>

	<newscontent date="18.July 2007" headline="SS HOLDING NEWS" link="http://www.orf.at">THE WORLD F I R ST CLIMATE CONTROLLED Championship Golf Course. It Is A  TOURISM ATTRACTION And A LANDMARK And Will Be A LEADING GOLF DESTINATION In The Future.This WORLD UNIQUE DEVELOPMENT Was Presented In Abu Dhabi The Capital Of The UAE To The Public And All Golf Enthusiasts!
	</newscontent>

	<newscontent date="19.July 2007" headline="SS HOLDING NEWS" link="http://www.orf.at">THE WORLD F I R ST CLIMATE CONTROLLED Championship Golf Course. It Is A  TOURISM ATTRACTION And A LANDMARK And Will Be A LEADING GOLF DESTINATION In The Future.This WORLD UNIQUE DEVELOPMENT Was Presented In Abu Dhabi The Capital Of The UAE To The Public And All Golf Enthusiasts!
	</newscontent>
	
	
	
</news>
 

Anhänge

  • text.fla
    27,5 KB · Aufrufe: 35
Hi,

Dein (unsinniger) Proto-MC überschreibt in jedem Schleifenaufruf den ersten News-Clip. Dieser wird nämlich auf der Tiefe (300+i) instanziert - der Proto-MC auf (300), was bei i=0 die selbe Tiefe ist. ;)

Warum machst Du es nicht einfach so?
Code:
	_root.createEmptyMovieClip("news_mc"+i, 300+i);
				
	_root["news_mc"+i].createTextField("date_txt", 310, 0, 0, 100, 20);
Den Quatsch mit duplicateMovieClip etc. brauchst Du wirklich nicht ...

Gruß
.
 
ich habe da noch eine schwierigkeit.. wollte zu dem ganzen jetzt ein archiv bauen... und in die funktion das i wieder mit dem inedx übergeben... aber irgendwie will mir das nicht gelingen... jemand einen tipp !? beim readmore aufruf t es wunderbar ! und beim archiv gar nicht !

PHP:
var xml_news:XML = new XML();
xml_news.ignoreWhite = true;

xml_news.onLoad = function()
	{
		var numOfNews:Number = 0;
		var nodes_news = this.firstChild.childNodes;
		var image = 0;
		
		numOfNews = nodes_news.length;
		_root.createTextField("latestnews_txt", 305, 0, 0, 100, 20);
				
		_root.latestnews_txt.setNewTextFormat(news_head_fmt); 
		_root.latestnews_txt.wordWrap = true;
		_root.latestnews_txt.multiline = true;
		_root.latestnews_txt.html = true;
		_root.latestnews_txt.selectable = false;
		_root.latestnews_txt.border = false;
		_root.latestnews_txt.antiAliasType = true;
		_root.latestnews_txt._y = 40;
		_root.latestnews_txt._x = breite-170;
				
		_root.latestnews_txt.htmlText = "LATEST NEWS";
		
		
		for(var i=0;i<3;i++)
			{	 
				_root.createEmptyMovieClip("news_mc"+i, 300+i);
				
				_root["news_mc"+i].createTextField("date_txt", 310, 0, 0, 100, 20);
				
				_root["news_mc"+i].date_txt.setNewTextFormat(news_date_fmt); 
				_root["news_mc"+i].date_txt.wordWrap = true;
				_root["news_mc"+i].date_txt.multiline = true;
				_root["news_mc"+i].date_txt.html = true;
				_root["news_mc"+i].date_txt.selectable = false;
				_root["news_mc"+i].date_txt.border = false;
				_root["news_mc"+i].date_txt.antiAliasType = true;
				_root["news_mc"+i].date_txt._y = 20;
				_root["news_mc"+i].date_txt._x = 0;
				
				_root["news_mc"+i].date_txt.htmlText = this.firstChild.childNodes[i].attributes.date;
				
				_root["news_mc"+i].createTextField("headline_txt", 320, 0, 0, 170, 20);	
				
				_root["news_mc"+i].headline_txt.setNewTextFormat(news_head_fmt); 
				_root["news_mc"+i].headline_txt.wordWrap = true;
				_root["news_mc"+i].headline_txt.multiline = true;
				_root["news_mc"+i].headline_txt.html = true;
				_root["news_mc"+i].headline_txt.selectable = false;
				_root["news_mc"+i].headline_txt.border = false;
				_root["news_mc"+i].headline_txt.antiAliasType = true;
				_root["news_mc"+i].headline_txt._y = 20;
				_root["news_mc"+i].headline_txt._x = 100;
				
				_root["news_mc"+i].headline_txt.htmlText = this.firstChild.childNodes[i].attributes.headline;
				
				_root["news_mc"+i].createTextField("news_txt", 330, 0, 0, 170, 150);
				
				_root["news_mc"+i].news_txt.setNewTextFormat(news_fmt); 
				_root["news_mc"+i].news_txt.wordWrap = true;
				_root["news_mc"+i].news_txt.multiline = true;
				_root["news_mc"+i].news_txt.html = true;
				_root["news_mc"+i].news_txt.selectable = false;
				_root["news_mc"+i].news_txt.border = false;
				_root["news_mc"+i].news_txt.antiAliasType = true;
				_root["news_mc"+i].news_txt._y = 40;
				_root["news_mc"+i].news_txt._x = 100;
				
				_root["news_mc"+i].news_txt.htmlText = this.firstChild.childNodes[i].childNodes;
				
				_root["news_mc"+i].news_txt.setLimitedText (_root["news_mc"+i].news_txt.text, 30);
	

				_root["news_mc"+i].createEmptyMovieClip("read_more_mc", 340)
				_root["news_mc"+i].read_more_mc._y = 80;
				_root["news_mc"+i].read_more_mc._x = 100;
				
				_root["news_mc"+i].read_more_mc.news_idx = i;
				
				_root["news_mc"+i].read_more_mc.createTextField("readmore_txt", 350, 0, 0, 170, 20);
					
				_root["news_mc"+i].read_more_mc.readmore_txt.setNewTextFormat(news_fmt); 
				_root["news_mc"+i].read_more_mc.readmore_txt.wordWrap = true;
				_root["news_mc"+i].read_more_mc.readmore_txt.multiline = true;
				_root["news_mc"+i].read_more_mc.readmore_txt.html = true;
				_root["news_mc"+i].read_more_mc.readmore_txt.selectable = false;
				_root["news_mc"+i].read_more_mc.readmore_txt.border = false;
				_root["news_mc"+i].read_more_mc.readmore_txt.antiAliasType = true;
				_root["news_mc"+i].read_more_mc.readmore_txt._y = 0;
				_root["news_mc"+i].read_more_mc.readmore_txt._x = 0;
				
				_root["news_mc"+i].read_more_mc.readmore_txt.htmlText = "[...read more]";
				
				_root["news_mc"+i]._y = 980+(90*i);
				_root["news_mc"+i]._x = breite-270;
				
				_root["news_mc"+i].bewegen(breite-270, 50+(90*i), 3);
				
				_root["news_mc"+i].read_more_mc.onRelease = function()
						{

							if (xml_news.firstChild.childNodes[this.news_idx].attributes.image.length <= 0)
								{
									bolNoImage = true;
								}
								
							contenterstellen();
							content_mc.contentbild_mc.loadMovie(xml_news.firstChild.childNodes[this.news_idx].attributes.image);
							content_mc.contenthead_mc.contenthead_txt.htmlText = xml_news.firstChild.childNodes[this.news_idx].attributes.date + " :: " + xml_news.firstChild.childNodes[this.news_idx].attributes.headline;
							content_mc.contenttext_mc.contenttext_txt.htmlText = xml_news.firstChild.childNodes[this.news_idx].childNodes;
							bolNoImage = false;
						}
				
					_root.createEmptyMovieClip("archiv_mc", 304);
						
					_root.archiv_mc.createTextField("archiv_txt", 306, 0, 0, 100, 20);
					_root.archiv_mc.archiv_txt.setNewTextFormat(news_head_fmt); 
					_root.archiv_mc.archiv_txt.wordWrap = true;
					_root.archiv_mc.archiv_txt.multiline = true;
					_root.archiv_mc.archiv_txt.html = true;
					_root.archiv_mc.archiv_txt.selectable = false;
					_root.archiv_mc.archiv_txt.border = false;
					_root.archiv_mc.archiv_txt.antiAliasType = true;
					_root.archiv_mc.archiv_txt._y = 340;
					_root.archiv_mc.archiv_txt._x = breite-170;
						
					_root.archiv_mc.archiv_txt.bewegen(340, breite-170, 3);
						
					_root.archiv_mc.archiv_txt.htmlText = "ARCHIV";
						
					_root.content_mc.createEmptyMovieClip("headline_mc"+i, 1000+i);
						
						
					_root.content_mc["headline_mc"+i].head_idx = i;
						
					_root.content_mc["headline_mc"+i].createTextField("headline_txt", 900, 0, 0, 700, 20);
					_root.content_mc["headline_mc"+i].headline_txt.setNewTextFormat(news_fmt); 
					_root.content_mc["headline_mc"+i].headline_txt.wordWrap = true;
					_root.content_mc["headline_mc"+i].headline_txt.multiline = true;
					_root.content_mc["headline_mc"+i].headline_txt.html = true;
					_root.content_mc["headline_mc"+i].headline_txt.selectable = false;
					_root.content_mc["headline_mc"+i].headline_txt.border = false;
					_root.content_mc["headline_mc"+i].headline_txt.antiAliasType = true;
					_root.content_mc["headline_mc"+i].headline_txt._y = -170+(30*i);
					_root.content_mc["headline_mc"+i].headline_txt._x = -345;
						
						//_root.content_mc["headline_mc"+i].headline_txt.htmlText = xml_news.firstChild.childNodes[i].attributes.date + " :: " + xml_news.firstChild.childNodes[i].attributes.headline;
						
						
					_root.archiv_mc.onRelease = function()
							{
								contenterstellen();
								bolNoImage = false;
								content_mc.headline_mc[this.head_idx].headline_txt.htmlText = xml_news.firstChild.childNodes[this.head_idx].attributes.date + " :: " + xml_news.firstChild.childNodes[this.head_idx].attributes.headline;
							}
								
					_root.content_mc["headline_mc"+i].onRelease = function()
							{
		
								if (xml_news.firstChild.childNodes[this.head_idx].attributes.image.length <= 0)
									{
										bolNoImage = true;
									}
										
								contenterstellen();
								content_mc.contentbild_mc.loadMovie(xml_news.firstChild.childNodes[this.head_idx].attributes.image);
								content_mc.contenthead_mc.contenthead_txt.htmlText = xml_news.firstChild.childNodes[this.head_idx].attributes.date + " :: " + xml_news.firstChild.childNodes[this.head_idx].attributes.headline;
								content_mc.contenttext_mc.contenttext_txt.htmlText = xml_news.firstChild.childNodes[this.head_idx].childNodes;
								bolNoImage = false;

							}
						
			}
	}


xml_news.load("xml/news.xml");
 
Da der Code doch recht lang ist, und in dieser Form nicht einfach ausgeführt werden kann, wäre es nett, wenn Du uns mitteilst, an welcher Stelle (Zeilenangabe) der Fehler ungefähr zu suchen ist.

Gruß
.
 
sorry...

also in dem teil past es da funktioniert alles wunderbar !

PHP:
_root["news_mc"+i].read_more_mc.onRelease = function()
                        {

                            if (xml_news.firstChild.childNodes[this.news_idx].attributes.image.length <= 0)
                                {
                                    bolNoImage = true;
                                }
                                
                            contenterstellen();
                            content_mc.contentbild_mc.loadMovie(xml_news.firstChild.childNodes[this.news_idx].attributes.image);
                            content_mc.contenthead_mc.contenthead_txt.htmlText = xml_news.firstChild.childNodes[this.news_idx].attributes.date + " :: " + xml_news.firstChild.childNodes[this.news_idx].attributes.headline;
                            content_mc.contenttext_mc.contenttext_txt.htmlText = xml_news.firstChild.childNodes[this.news_idx].childNodes;
                            bolNoImage = false;
                        }


mache ich aber das selbe mit dem hier !

PHP:
 _root.archiv_mc.onRelease = function()
                            {
                                contenterstellen();
                                bolNoImage = false;
                                content_mc.headline_mc[this.head_idx].headline_txt.htmlText = xml_news.firstChild.childNodes[this.head_idx].attributes.date + " :: " + xml_news.firstChild.childNodes[this.head_idx].attributes.headline;
                            }
                                
                    _root.content_mc["headline_mc"+i].onRelease = function()
                            {
        
                                if (xml_news.firstChild.childNodes[this.head_idx].attributes.image.length <= 0)
                                    {
                                        bolNoImage = true;
                                    }
                                        
                                contenterstellen();
                                content_mc.contentbild_mc.loadMovie(xml_news.firstChild.childNodes[this.head_idx].attributes.image);
                                content_mc.contenthead_mc.contenthead_txt.htmlText = xml_news.firstChild.childNodes[this.head_idx].attributes.date + " :: " + xml_news.firstChild.childNodes[this.head_idx].attributes.headline;
                                content_mc.contenttext_mc.contenttext_txt.htmlText = xml_news.firstChild.childNodes[this.head_idx].childNodes;
                                bolNoImage = false;

                            }

bekomme ich nur werte mit undifine !
 
Hmm, ich steige immer noch nicht durch den Code durch. Welchen Wert welches Objektes fragst Du wo ab?

Poste bitte mal die .fla und die dazugehörige XML-Datei, damit ich das auf meinem System testen kann; AS-Kompiler zu spielen, ist mir zu anstrengend. ;)

Gruß
.
 
Zurück