Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

italic text from xml file to create dynamic menu

Community Beginner ,
Jul 29, 2009 Jul 29, 2009

Hi,

I have a working menu that pulls in data from an XML file. The movie clips are attached to the stage dynamically based on the number of XML items. I need most of the text formatted regularly, but one button requires some html formatted text. (italics). I've set the text box in Flash to html = true.

Here is some of my code:

tl["btn"+(i)].blackTxt.Txt.html = true;

tl["btn"+(i)].whiteTxt.Txt.html = true;

//Place the button name from names Array into the blackTxt text box

tl["btn"+(i)].blackTxt.Txt.htmlText = (names);

//Place the button name from names Array into the whiteTxt text box

tl["btn"+(i)].whiteTxt.Txt.htmlText = (names);

//XML

<BUTTON LINK='http://www.website.com/'><![CDATA[text here <i>italics here</i> text here]]></BUTTON>

When it shows up in Flash, I can see the <i> tags and none of the text is formatted in italics.

Any ideas? Thanks for the help.

TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2009 Jul 29, 2009

use the firstChild.nodeValue to assign names

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 29, 2009 Jul 29, 2009

I may not have provided enough context. Here is more of the code:

myXML.onLoad = function(){

//Set varible to store the XML childNodes

//This allows you to get the number of buttons in the XML file.

//You'll use this tell flash how many times to loop the for loop.

var linkname:Array = this.firstChild.childNodes;

//Set a for loop

for(i=0;i<linkname.length;i++){

//Push the button name into the names Array

if (linkname.attributes.NAME) {

names.push(linkname.attributes.NAME);

}

else {

names.push(linkname);

}

//Push the button link into the links Array

links.push(linkname.attributes.LINK);

//Attach the button Movie Clip from the libray give it an instance name and place it on the next highest level

tl.attachMovie("button","btn"+i,tl.getNextHighestDepth());

//Set the y position of the buttons

tl["btn"+i]._y = yPosition;

//Increace the varible yPosition 15 pixel each time the loop runs to place each button under each other

yPosition = yPosition + 18;

//set text to html text

tl["btn"+(i)].blackTxt.Txt.html = true;

tl["btn"+(i)].whiteTxt.Txt.html = true;

//Place the button name from names Array into the blackTxt text box

tl["btn"+(i)].blackTxt.Txt.htmlText = (names);

//Place the button name from names Array into the whiteTxt text box

tl["btn"+(i)].whiteTxt.Txt.htmlText = (names);

//Assign the btnOver function to the button onRollOver state.

tl["btn"+(i)].onRollOver = btnOver;

//Assign the btnOut function to the button onRollOut state.

tl["btn"+(i)].onRollOut = btnOut;

//Assign the btnRelease function to the button onRelease state.

tl["btn"+(i)].onRelease = btnRelease;

}

}

//xml

<NAVBAR>

   <BUTTON LINK='http://www.google.com'><![CDATA[text <i>italic text</i> text]]></BUTTON>

   <BUTTON NAME='button 1' LINK='http://www.google.com' />

</NAVBAR>

Thanks for the quick response.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2009 Jul 29, 2009

again, use firstChild.nodeValue:


myXML.onLoad = function(){

//Set varible to store the XML childNodes

//This allows you to get the number of buttons in the XML file.

//You'll use this tell flash how many times to loop the for loop.

var linkname:Array = this.firstChild.childNodes;

//Set a for loop

for(i=0;i<linkname.length;i++){

//Push the button name into the names Array

if (linkname.attributes.NAME) {

names.push(linkname.attributes.NAME);

}

else {

names.push(linkname.firstChild.nodeValue);

}

//Push the button link into the links Array

links.push(linkname.attributes.LINK);

//Attach the button Movie Clip from the libray give it an instance name and place it on the next highest level

tl.attachMovie("button","btn"+i,tl.getNextHighestDepth());

//Set the y position of the buttons

tl["btn"+i]._y = yPosition;

//Increace the varible yPosition 15 pixel each time the loop runs to place each button under each other

yPosition = yPosition + 18;

//set text to html text

tl["btn"+(i)].blackTxt.Txt.html = true;

tl["btn"+(i)].whiteTxt.Txt.html = true;

//Place the button name from names Array into the blackTxt text box

tl["btn"+(i)].blackTxt.Txt.htmlText = (names);

//Place the button name from names Array into the whiteTxt text box

tl["btn"+(i)].whiteTxt.Txt.htmlText = (names);

//Assign the btnOver function to the button onRollOver state.

tl["btn"+(i)].onRollOver = btnOver;

//Assign the btnOut function to the button onRollOut state.

tl["btn"+(i)].onRollOut = btnOut;

//Assign the btnRelease function to the button onRelease state.

tl["btn"+(i)].onRelease = btnRelease;

}

}

//xml

<NAVBAR>

   <BUTTON LINK='http://www.google.com'><![CDATA[text <i>italic text</i> text]]></BUTTON>

   <BUTTON NAME='button 1' LINK='http://www.google.com' />

</NAVBAR>

Thanks for the quick response.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 29, 2009 Jul 29, 2009

Thanks Kglad. I tried this but it doesn't seem to be working correctly. Everything between the "<i>the text between these tags is removed</i>" is removed from the string.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2009 Jul 29, 2009

are you doing something that requires an embedded font and you're failing to embed italic font?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 29, 2009 Jul 29, 2009

Yes, I am embedding the font. I know I have the regular version of the font embedded. Is there any special trick to embedding two fonts for the same text box? I tried embedding the italic version too, but maybe I did something wrong.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2009 Jul 29, 2009

the easiest way to embed italic font is to create a textfield (offstage and/or not visible) and embed the font like normal and toggle the italic button.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 30, 2009 Jul 30, 2009

Thanks Kglad! The menu is working now with regular and italic fonts.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 30, 2009 Jul 30, 2009
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines