2
AS2新手在這裏,我想知道是否有人可以幫我用下面的代碼。基本上我想要做的是將另一個字段添加到已經用於填充從activeden獲得的AS2新聞滾動器的XML文件。你會注意到我已經嘗試了複製日期字段並添加一個月份字段,但它似乎沒有工作。任何幫助將不勝感激。我的代碼如下。將另一個XML字段添加到AS2腳本
XML:
<?xml version=".0" encoding="utf-8" ?>
<xml>
<settings
newswidth = "320"
newsheight = "390"
timer = "200"
bgAlpha = "90"
dateColor = "0xEAEAEA"
newsBgColor = "0x3E3E3E"
dateBgColor = "0x3E3E3E"
navIconColor = "0x222222"
navBgColor = "0xFFFFFF"
>
</settings>
<allnews>
<news>
<day><![CDATA[<a href="http://activeden.net/user/designesia">01</a>]]></day>
<month>DEC</month>
<text><![CDATA[<a href="http://activeden.net/user/designesia">Recalls</a>]]></text>
<url>http://activeden.net/user/designesia</url>
<window>2</window>
</news> etc.
的ActionScript:
//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<=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 & 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<>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>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<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>=timer){
if(page<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;
}
}
}
}