[XML] text style

well i read on how to make a dynamic menu with xml, but thats not what i wanna do and i cant get it to work with the AS to suit my needs.

so what i have is


 
  <newsmain>
     <article>
       <title>Some title</title>
       <date>some date</date>
       <autor>Some silly name</autor>
     </article>
     <article>
       <title>Some title</title>
       <date>some date</date>
       <autor>Some silly name</autor>
     </article>
     <article>
       <title>Some title</title>
       <date>some date</date>
       <autor>Some silly name</autor>
     </article>
   </newsmain>

  

i have that xml stuff…

i need to give it some format, some html tags maybe font color… bold… etc…

i want to load that in a text box.

Please help?

Thanks :slight_smile:

(i alredy read the senocular kirupra tuts and nada)


menuXml = new XML();
menuXml.ignoreWhite = true;
menuXml.onLoad = function() {
	menuItem = this.firstChild.childNodes;
	for (var i=0; i<menuItem.length; i++) {
		item = _root.attachMovie("itemClip", "itemClip" + i, i);
		item._x = 0;
		item._y = 20*i;
		item.itemLabel.text = menuItem*.attributes.name;
		item.myUrl.text = menuItem*.attributes.url;
		//item.onRelease = function() {
		//	getURL(this.myUrl,"_blank");
		//}
	}
}
menuXml.load("menu.xml");

im using that taking the menu tutorial for reference.
i created a movie clip naed itemClip and that duplicates depending on the num of nodes.

so i just made 2 dynamic text fields (itemLabel, myUrl)
and the text displays ok there…

but… is this the most efficent way to do it?

also is not in a TEXTBOX so … HELP!!!

Thanks :smiley:

help me :frowning:

[AS]item.itemLabel…html = true;
item.itemLabel.htmlText = menuItem*.attributes.name;
item.myUrl.html = true;
item.myUrl.htmlText = menuItem*.attributes.url;[/AS]

To be able to use font formatting tags like that you have to render the textboxes to read HTML (albeit limited font formatting HTML, but still HTML none the less).

THANKS Lost!

im understanding it better…

but i want to put the HTML tags in the AS, any example to get started?

Why not just add it with your text in the XML file? It would be easier on you if thats the text you want to be effected by your font formatting HTML tags.

but then i will have a big xml full of tags?

i want the AS To loop and loop and format each node itself.

what u think?

Well then add the tags in the AS.

[AS]item.itemLabel.htmlText = “<B>”+menuItem*.attributes.name;+"</B>"[/AS]

Something like that should work.

nice.

gonna make some examples and see if it works

thanks man :slight_smile:

Question though: If the entire text is those textboxes are all going to have the same format… why not just format it like that on the textbox itself through the properties?

no that was an example

the text i want to put it in 1 textbox only and fill it automatically with the XML/AS so if i update something i just add nodes and text. and the AS does the text format.

and i wanna do it scrollable…

no problem with the things we got so far right?

thanks!

Be back tomorrow!

Alright… I thought you were using seperate textboxes for each thing, in that case it would have been easier to format the textboxes manually, but since it is just one textbox, you can’t do that, so I understand now.

almost there… i think

ok here is what i got.


the AS.
menuXml = new XML();
menuXml.ignoreWhite = true;
menuXml.onLoad = function() {
	menuItem = this.firstChild.childNodes;
	for (var i=0; i<menuItem.length; i++) {
	_root.itemClip.html = true;
    _root.itemClip.htmlText = "<br><b>"+menuItem*.attributes.name+"</b><br>"+menuItem*.attributes.url;

	}
}
menuXml.load("menu.xml");


the XML FILE

<?xml version="1.0"?>	
<myMenu>	
<myItem name="Philter" url="http://www.philterdesign.com/" />
		<myItem name="Keran McKenzie" url="http://pnut.studiowhiz.com/" />		
<myItem name="StudioWhiz" url="http://www.studiowhiz.com/" />		
<myItem name="Macromedia" url="http://www.macromedia.com/" />		
<myItem name="FlashForward" url="http://www.flashforward2002.com/" />
		<myItem name="Electric Rain" url="http://www.erain.com/" />
		<myItem name="Friends of Ed" url="http://www.friendsofed.com/" />
		<myItem name="Swish" url="http://www.swishzone.com/" />
		<myItem name="New Riders" url="http://www.newriders.com/" />
		<myItem name="LastNode" url="http://www.sorenson.com/" />	
</myMenu>

is just an example file…

i got 1 Dynamic box, named itemClip in 1 frame with the AS in the frame.

when i run the test it displays the LastNode (last item on list) only.

why is that?

maybe the for loop is wrong? but it seems ok.

lil help almost there.