Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding another XML field to AS2 script
    primarykey
    data
    text
    <p>AS2 newbie here, and I want to know if anybody can help me with the following code. Basically what I want to do is add another field to an XML file that is already being used to populate a AS2 news scroller that I got from activeden. You will notice that I have tried duplicate the day field and add a month field in but it does not seem to be working. Any help would be greatly appreciated. My code is below.</p> <p>XML:</p> <pre><code>&lt;?xml version=".0" encoding="utf-8" ?&gt; &lt;xml&gt; &lt;settings newswidth = "320" newsheight = "390" timer = "200" bgAlpha = "90" dateColor = "0xEAEAEA" newsBgColor = "0x3E3E3E" dateBgColor = "0x3E3E3E" navIconColor = "0x222222" navBgColor = "0xFFFFFF" &gt; &lt;/settings&gt; &lt;allnews&gt; &lt;news&gt; &lt;day&gt;&lt;![CDATA[&lt;a href="http://activeden.net/user/designesia"&gt;01&lt;/a&gt;]]&gt;&lt;/day&gt; &lt;month&gt;DEC&lt;/month&gt; &lt;text&gt;&lt;![CDATA[&lt;a href="http://activeden.net/user/designesia"&gt;Recalls&lt;/a&gt;]]&gt;&lt;/text&gt; &lt;url&gt;http://activeden.net/user/designesia&lt;/url&gt; &lt;window&gt;2&lt;/window&gt; &lt;/news&gt; etc. </code></pre> <p>Actionscript:</p> <pre><code>//XML NEWS SCROLLER BY DESIGNESIA 2 stop(); var myxml = new XML(); var newsAr:Array = new Array(); var ypos = 0; var page = 0; var t = 0; myxml.ignoreWhite = true; myxml.load("news.xml"); import mx.transitions.Tween; import mx.transitions.easing.*; newsclip.mc._visible = false; setColor = function(mc,varColor){ var mycolor:Color = new Color(mc); mycolor.setRGB(varColor); } myxml.onLoad = function(success){ if(success){ // ===== GET GLOBAL SETTINGS FROM XML ===== settings = myxml.firstChild.childNodes[0].attributes; mask._width = settings.newswidth; mask._height = settings.newsheight; bgAlpha = Number(settings.bgAlpha); timer = Number(settings.timer); // ===== COLOR SETTINGS ===== //dateColor = settings.dateColor; newsBgColor = settings.newsBgColor; dateBgColor = settings.dateBgColor; navIconColor = settings.navIconColor; navBgColor = settings.navBgColor; // ===== PRE INIT ===== btnUp._alpha = bgAlpha; btnDown._alpha = bgAlpha; btnUp._x = mask._width - btnUp._height - 100; btnDown._x = mask._width - btnUp._height - 140; btnUp._y = mask._height + 18; btnDown._y = btnUp._y; // ===== CSS FOR TEXT ===== var style = new TextField.StyleSheet(); style.setStyle("a:link", {textDecoration:'none'}); style.setStyle("a:hover", {textDecoration:'underline'}); style.setStyle("em", {textDecoration:'underline'}); // ===== NEWS COUNT ===== total = myxml.firstChild.childNodes[1].childNodes.length; // ===== GENERATE NEWS ===== for(i=1;i&lt;=total;i++){ duplicateMovieClip("newsclip.mc","mc"+i,i); newsAr[i] = eval("newsclip.mc" + i); newsAr[i]._y = newsAr[i-1]._y + 91; newsAr[i]._alpha = bgAlpha; newsAr[i].bg._width = mask._width; // ===== DATE ===== newsAr[i].date.txt.text = myxml.firstChild.childNodes[1].childNodes[i-1].childNodes[0].childNodes[0].nodeValue; newsAr[i].date.txt.text = newsAr[i].date.txt.text.toUpperCase() setColor(newsAr[i].bgdate,dateBgColor); // ===== MONTH ===== newsAr[i].date.txt2.text = myxml.firstChild.childNodes[1].childNodes[i-1].childNodes[1].childNodes[0].nodeValue; newsAr[i].date.txt2.text = newsAr[i].date.txt2.text.toUpperCase() setColor(newsAr[i].bgdate,dateBgColor); // ===== VARIABLE &amp; SETTINGS FOR TEXT ===== newsAr[i].teks.txt._width = mask._width - 20; newsAr[i].teks.txt.multiline = true; newsAr[i].teks.txt.selectable = false; newsAr[i].teks.txt.html = true; newsAr[i].teks.txt.htmlText = myxml.firstChild.childNodes[1].childNodes[i-1].childNodes[2].childNodes[0].nodeValue; newsAr[i].teks.txt.styleSheet = style; // ===== BACKGROUND ===== //setColor(newsAr[i].bg,newsBgColor); // ===== URL ===== newsAr[i].link = myxml.firstChild.childNodes[1].childNodes[i-1].childNodes[3].childNodes[0].nodeValue; newsAr[i].wd = Number(myxml.firstChild.childNodes[1].childNodes[i-1].childNodes[3].childNodes[0].nodeValue); // ===== ADD BUTTON FUNCTION ===== newsAr[i].onRelease = function(){ if(this.link&lt;&gt;undefined){ if(this.wd==1){ getURL(this.link,"_self"); }else{ getURL(this.link,"_blank"); } } } // CLOSE newsAr[i].onRelease newsAr[i].onRollOver = function(){ var HTween1:Tween = new Tween (this,"_alpha",Strong.easeOut,bgAlpha,100,1,true); } newsAr[i].onRollOut = function(){ var HTween1:Tween = new Tween (this,"_alpha",Strong.easeOut,100,bgAlpha,1,true); } } // ===== CLOSE FOR ===== // ===== ACTION FOR NAVIGATION BUTTONS ===== // ===== SET COLOR ==== setColor(btnUp.bg,navBgColor); setColor(btnDown.bg,navBgColor); setColor(btnUp.ico,navIconColor); setColor(btnDown.ico,navIconColor); btnUp.onRelease = function(){ t = 0; if(page&gt;0){ page--; ypos+=91; var HTween1:Tween = new Tween (newsclip,"_y",Strong.easeIn,newsclip._y,ypos,.5,true); } } btnUp.onRollOver = function(){ var HTween1:Tween = new Tween (this,"_alpha",Strong.easeOut,bgAlpha,100,1,true); } btnUp.onRollOut = function(){ var HTween1:Tween = new Tween (this,"_alpha",Strong.easeOut,100,bgAlpha,1,true); } btnDown.onRelease = function(){ t = 0; if(page&lt;total-5){ page++; ypos-=80; var HTween1:Tween = new Tween (newsclip,"_y",Strong.easeIn,newsclip._y,ypos,.5,true); }else{ page = 0; ypos = 0; var HTween1:Tween = new Tween (newsclip,"_y",Strong.easeIn,newsclip._y,ypos,.5,true); } } btnDown.onRollOver = function(){ var HTween1:Tween = new Tween (this,"_alpha",Strong.easeOut,bgAlpha,100,1,true); } btnDown.onRollOut = function(){ var HTween1:Tween = new Tween (this,"_alpha",Strong.easeOut,100,bgAlpha,1,true); } // ===== ROTATE THE NEWS ===== newsclip.onEnterFrame = function(){ t++; if(t&gt;=timer){ if(page&lt;total-5){ page++; ypos-=80; var HTween1:Tween = new Tween (newsclip,"_y",Strong.easeIn,newsclip._y,ypos,.5,true); }else{ page = 0; ypos = 0; var HTween1:Tween = new Tween (newsclip,"_y",Strong.easeIn,newsclip._y,ypos,.5,true); } t = 0; } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload