Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML and CDATA showing HTML tags 1

Status
Not open for further replies.

websh

Technical User
Jan 8, 2002
13
US
Hi all,

I am hopeful someone can recommend a solution to my dilemma. Here is what I have...

I am building a simple Flash tutorial with an XML file, two movie clips that act as &quot;Next&quot; & &quot;Previous&quot; buttons and a textbox placeholder for content from the XML file. I am using <![CDATA[...]]> in the XML so I can format the content with HTML tags.

My XML looks something like this...

<lesson>
<screen audio=&quot;scriptclip1.mp3&quot; artwork=&quot;image1.jpg&quot;>
<![CDATA[<b>Lesson 1</b> text goes here]]>
</screen>
<screen audio=&quot;scriptclip2.mp3&quot; artwork=&quot;image2.jpg&quot;>
<![CDATA[Lesson 2 text goes here]]>
</screen>
<screen audio=&quot;scriptclip3.mp3&quot; artwork=&quot;movie.swf&quot;>
<![CDATA[Lesson 3 text goes here]]>
</screen>
</lesson>

The functionality of the tutorial works just fine, however, the text formatting is rendering the HTML tags. I am stumped about how to code this properly and it is highly possible I am missing something simple. I have also spent quite abit of time in this forum and others reading what I could about the use of XML and CDATA, but couldn't quite get my actionscript to work.

Here is what the script looks like:

drawScreen = function(){
info_txt.text = lessonList[currentScreen];
info_txt.background = true;
info_txt.border = true;
info_txt.borderColor = 0xC0C0C0;

if (currentScreen == 0){
prev_mc._visible = false;
}else{
prev_mc._visible = true;
}
if (currentScreen == lessonList.length-1){
next_mc._visible = false;
}else{
next_mc._visible = true;
}
}
next_mc.onRelease = function(){
stopAllSounds();
++currentScreen;
drawScreen();
}
prev_mc.onRelease = function(){
stopAllSounds();
--currentScreen;
drawScreen();
}
currentScreen = 0;
lessonList = new Array();
lesson_xml = new XML();
lesson_xml.ignoreWhite = true;
lesson_xml.onLoad = function(){
var screenNode = this.firstChild.firstChild;
var audioClip = this.firstChild.firstChild.attributes.audio;
while (screenNode != null){
lessonList.push(screenNode.firstChild.nodeValue);
screenNode = screenNode.nextSibling;
soundHolder = new Sound();
soundHolder.loadSound(audioClip);
soundHolder.start(0);
}
drawScreen();
}
lesson_xml.load(&quot;lesson.xml&quot;);

Any ideas anyone?

Thanks,

websh
 
Simply enable html in your textfield's properties... The (<>) icon/tab.

Or do it in AS...
AND USE .htmlText rather .text alone...

drawScreen = function(){
info_txt.html = true;
info_txt.htmlText = lessonList[currentScreen];
...



Regards,

cubalibre2.gif
 
Thanks, oldnewbie!

Regarding your first comment:

>Simply enable html in your textfield's properties... The (<>) icon/tab.

I made sure the feature was set in the Properties panel.

Secondly, I had used the following two lines:

>info_txt.html = true;
>info_txt.htmlText = lessonList[currentScreen];

in one of my attempts, but put the code in the wrong place!

Looks like I was on the right track, just placing code in inappropriate places.

While we are on the subject, may I pose another question?

If you noticed in my XML file, I have some attributes that reference a voiceover clip to load with the content. The first clip loads and plays just fine, but subsequent clips do not play. Any ideas?

Thanks again!

websh
 
Sorry, but I've never really worked with XML.
Don't think your problem is XML related though.
Try commenting out your stopAllSounds() action, to see if the other ones do start up. They'll probably overlap each other, if they do, but you'll at least know it's probably not XML related, and should look into your starting and stopping of sounds' code.

Regards,

cubalibre2.gif
 
Hi all,

Thanks for the previous remarks and suggestions. They were helpful.

I am still having some trouble with my code getting the images referenced in the XML file (see code above from earlier post) to load. Though a movie clip is not referenced in the code example, I have added a movie clip to the stage and given it an instance name to serve as a container for each image.

I have tried several ways to reference the node containing the attribute and value and then load it in the movie clip, but I am not having much success.

Any ideas or help would be very much appreciated.

Thanks again,

websh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top