Actionscript 2.0 Repeat Movieclip XML data

I'm trying to repeat a movie clip on the _y axis, that contains XML data. So far, testing my movie will duplicate the movie clip, only on top of itself. How can I force the repeating movie clips to list vertically?

The flash actionscript is below


MyXML = new XML();
 
MyXML.ignoreWhite = true; 
 
MyXML.onLoad = function(ok) { 
 
if (ok) {
 
   allNodes = this.firstChild.childNodes;
		 
   for (var i = 0; i<3; i++) {
			
      _root.jtitle = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
      
      _root.jdate = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue; 
   
      _root.jtext = this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue; 
			
      duplicateMovieClip (_root.entry_content.entry_info, "mc"+i, i);
 
      _root.entry_height = _root.entry_content["mc"+i]._height;
			
      _root.entry_content["mc"+i].title_txt.text = _root.jtitle;
				  
      _root.entry_content["mc"+i].date_txt.text = _root.jdate;
				 
      _root.entry_content["mc"+i].entry_txt.text = _root.jtext;			
				
      trace(_root.jtitle);
      trace(_root.jdate);
      trace(_root.jtext);
				
}
			
} else {
		  
   trace('error');
			
   }
};
 
MyXML.load('../xml/journal.xml');

Open in new window

webrhpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

crooksy88Commented:
You have to set the Y property for each of the movieclips you add.

e.g.

duplicateMovieClip (_root.entry_content.entry_info, "mc"+i, i);

setProperty(_root.entry_content["mc"+i], _y, i*50);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
webrhpAuthor Commented:
This works great! So simple!

But I have one final question before I award...

Would you happen to know how to set the height of my "entry_txt" field to auto?

Basically, repeating the rows works perfectly, but if my XML content is larger than my text field, I get an overlapping. I'd like this repetition to begin, at the bottom of the repeated movie.

Essentially allowing unlimited length to each entry.

Any help is appreciated, and let me know if this requires more points to solve. Thanks so much.
MyXML = new XML();
 
MyXML.ignoreWhite = true;
 
MyXML.onLoad = function(ok) {
      if (ok) {
 
		    allNodes = this.firstChild.childNodes;
		 
            for (var i = 0; i<10; i++) {
			
				_root.jtitle = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
				_root.jdate = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
				_root.jtext = this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue;
			
				duplicateMovieClip (_root.entry_content.entry_info, "mc"+i, i);
 
				setProperty(_root.entry_content["mc"+i], _y, i*100);			
				
				_root.entry_content["mc"+i].title_txt.text = _root.jtitle;
				_root.entry_content["mc"+i].date_txt.text = _root.jdate;
				_root.entry_content["mc"+i].entry_txt.text = _root.jtext;			
				
				trace(_root.jtitle);
				trace(_root.jdate);
				trace(_root.jtext);
			
            }
			
      } else {
		  
            trace('error');
			
      }
};
 
MyXML.load('../xml/journal.xml');

Open in new window

0
crooksy88Commented:
Unfortunately I don't quite understand what you're saying. Could you post the file somewhere so I could take a look and see what you are meaning?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

webrhpAuthor Commented:
Below is a link to a zip file containing my .swf and .xml files organized already.

Run the .swf and you'll see my dilemma.

http://sensorywithin.com/files/flash-xml-journal.zip
0
crooksy88Commented:
I see! Although this isn't a complete solution it should get you going on the right path.

in this order...

Duplicate the movie clip

Add the text to the fields

Trace out the _height value of each movieclip so you can see it's height value. trace(_root.entry_content["mc"+i]._height);

If you are seeing the different height values in the output window then you know you can use this info to correctly space the movieclips.

Something like
//get the y value of the previous movieclip
var yval = getProperty(_root.entry_content["mc"+i-1], _y);

//get the height value of the previous movieclip
var hval = getProperty(_root.entry_content["mc"+i-1], _height)

// using the two figures from above, position the new movieclip
// this would add a 20px gap between each movieclip
setProperty(_root.entry_content["mc"+i], _y, yval+(hval+20));




0
webrhpAuthor Commented:
Oh very cool. I understand where you are going.

Only, tracing the height of my clip, returns only the same value.

I'll accept your previous help, any suggestions?

Thank you
0
crooksy88Commented:
I think you might have to get the height value of the text field within the movieclip rather than the movieclip itself.
0
webrhpAuthor Commented:
A few syntax issues and now it works!!!!

Thank you so much for your help!

I need to know how to fix my loop, so it doesn't rely on a maximum number. Any ideas?

My final code is below, to anyone who needs help with this type of operation.


MyXML = new XML();
MyXML.ignoreWhite = true;
MyXML.onLoad = function(ok) {
 
if (ok) {
 
// Loop Limit
_root.max_entries = 10;
 
for (var i = 0; i < _root.max_entries; i++) {
 
// Put XML Contents into Variables
_root.jtitle = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
_root.jdate = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
_root.jtext = this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue;				
	//trace(_root.jtitle);
	//trace(_root.jdate);
	//trace(_root.jtext);
 
// Duplicate Entry clip, and Assign New Dynamic Name
duplicateMovieClip (_root.entry_content.entry_info, "mc"+i, i);
 
// Wrap Size of Major Text Field to Size of Content
_root.entry_content["mc"+i].entry_txt.autoSize = "center";					
 
// Enter Text from XML Into Movie Clip
_root.entry_content["mc"+i].title_txt.text = _root.jtitle;
_root.entry_content["mc"+i].date_txt.text = _root.jdate;
_root.entry_content["mc"+i].entry_txt.text = _root.jtext;			
 
// Get the y value of the previous movieclip
var yval = getProperty(_root.entry_content["mc" + (i - 1)], _y);
	// trace("previous clip y position " + yval);
 
// Get the height value of the previous movieclip
var hval = getProperty(_root.entry_content["mc" + (i - 1)], _height)
	// trace("height of previous clip " + hval);
 
// Space in pixels between each clip
_root.mc_spacing = 10;
 
// Using the two figures from above, position the new movieclip
setProperty(_root.entry_content["mc"+i], _y, yval + (hval + _root.mc_spacing));
 
}
 
} else {
 
// If XML isn't loaded, trace error
trace('Error XML Not Loaded!');
 
}
 
};
 
// Load XML File
MyXML.load('../xml/journal.xml');

Open in new window

0
crooksy88Commented:
if (ok) {

xmlNodeLength = this.firstChild;
_root.max_entries = xmlNodeLength.childNodes.length;
0
webrhpAuthor Commented:
Very nice!

Now, I have another question open for the points if you'd like to post this there.

http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/ActionScript/Q_23919316.html

I'm also looking for a way to add links into the text loaded in from the XML, any ideas?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.