|
|
ใครพอช่วยเรื่อง xml + action script ให้ขึ้นบรรทัดใหม่ได้บ้างเข้ามาช่วยหน่อยครับแก้ไม่ได้ซักที |
|
|
|
|
|
|
|
ส่วนนี้เป็น xml code น่ะครับ
<content>
<category>
<title>Dinamic Oil</title>
<xml>news/news_category_1.xml</xml>
</category>
<category>
<title>Tramec</title>
<xml>news/news_category_2.xml</xml>
</category>
<category>
<title>Bonfiglioil</title>
<xml>news/news_category_3.xml</xml>
</category>
<category>
<title>Flender</title>
<xml>news/news_category_4.xml</xml>
</category>
<category>
<title>Induction motor</title>
<xml>news/news_category_5.xml</xml>
</category>
<category>
<title>Vibrator technology</title>
<xml>news/news_category_6.xml</xml>
</category>
<category>
<title>Screw conveyor</title>
<xml>news/news_category_7.xml</xml>
</category>
<category>
<title>Neutrino worm gear</title>
<xml>news/news_category_8.xml</xml>
</category>
<category>
<title>Force cyclodrive</title>
<xml>news/news_category_9.xml</xml>
</category>
<category>
<title>KTR Coupling</title>
<xml>news/news_category_10.xml</xml>
</category>
<category>
<title>SAM BO clutch</title>
<xml>news/news_category_11.xml</xml>
</category>
<category>
<title>Poggi bevel gearbox</title>
<xml>news/news_category_12.xml</xml>
</category>
<category>
<title>Automation technology</title>
<xml>news/news_category_13.xml</xml>
</category>
</content>
ส่วนนี้เป็น Action Script นะครับ
import mx.transitions.Tween;
import mx.transitions.easing.*;
var lastCategory = 0;
var thisButt = 0;
/////////////Load XML Data/////////////
category = new XML();
category.ignoreWhite = true;
category.onLoad = function(success) {
if (success) {
xmlNode = this.firstChild;
Title = [];
_global.link = [];
total = xmlNode.childNodes.length;
for (var i = 0; i<total; i++) {
Title[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
_global.link[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
categories_holder.attachMovie("catgoriesItem","item"+i,i+999);
categories_holder["item"+i].title_txt.text = Title[i];
categories_holder["item"+i].id = i;
categories_holder["item"+i].title_txt.autoSize = true;
categories_holder["item"+i]._x = (categories_holder["item"+(i-1)]._x+categories_holder["item"+(i-1)].title_txt._width+10);
categories_holder["item"+i].line_mc._x = (categories_holder["item"+i].title_txt._width+5);
categories_holder["item"+[total-1]].line_mc._alpha = 0;
categories_holder["item"+i]._y = 0;
block_mc._width = categories_holder._width-5;
right_mc._x = block_mc._width+25;
categories_holder["item"+thisButt].title_txt._alpha = 50;
categories_holder["item"+thisButt].button_bttn.enabled = false;
categories_holder["item"+i].button_bttn._width = categories_holder["item"+i].title_txt._width;
categories_holder["item"+i].button_bttn.onRollOver = function() {
categories_holder["item"+[this._parent.id]].title_txt._alpha = 50;
};
categories_holder["item"+i].button_bttn.onRollOut = function() {
categories_holder["item"+[this._parent.id]].title_txt._alpha = 100;
};
categories_holder["item"+i].button_bttn.onRelease = function() {
smallNews_mc.scrollBttn._y = 0;
smallNews_mc.holder_mc._y = 0;
scrollBttn._y = 30;
holder_mc._y = 30;
for (var i = 0; i<total; i++) {
removeMovieClip(smallNews_mc.holder_mc["news_Item"+i]);
}
xmlData.load(_global.link[this._parent.id]);
lastCategory = this.id;
categories_holder["item"+thisButt].title_txt._alpha = 100;
categories_holder["item"+thisButt].button_bttn.enabled = true;
thisButt = this._parent.id;
categories_holder["item"+thisButt].title_txt._alpha = 50;
categories_holder["item"+thisButt].button_bttn.enabled = false;
};
xmlData.load(_global.link[0]);
if (total < 2) {
categories_holder._visible = false;
}
}
}
};
category.load("news/news.xml");
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
thumb = [];
Title = [];
date = [];
BigNews = [];
short = [];
total = xmlNode.childNodes.length;
for (var i = 0; i<total; i++) {
thumb[i] = xmlNode.childNodes[i].childNodes[0].childNodes[0].nodeValue;
Title[i] = xmlNode.childNodes[i].childNodes[1].childNodes[0].nodeValue;
date[i] = xmlNode.childNodes[i].childNodes[2].childNodes[0].nodeValue;
short[i] = xmlNode.childNodes[i].childNodes[3].childNodes[0].nodeValue;
BigNews[i] = xmlNode.childNodes[i].childNodes[4].childNodes[0].nodeValue;
smallNews_mc.holder_mc.attachMovie("newsItem","news_Item"+i,i+999);
smallNews_mc.holder_mc["news_Item"+i].id = i;
smallNews_mc.holder_mc["news_Item"+i]._x = 0;
smallNews_mc.holder_mc["news_Item"+i]._y = i*93;
smallNews_mc.holder_mc["news_Item"+i].date_txt.text = date[i];
smallNews_mc.holder_mc["news_Item"+i].author_txt.text = Title[i];
smallNews_mc.holder_mc["news_Item"+i].short_txt.htmlText = short[i];
smallNews_mc.holder_mc["news_Item"+i].short_txt.autoSize = true;
smallNews_mc.holder_mc["news_Item"+i].holder_mc.loadMovie(thumb[i],1);
MoveNav = new Tween(scrollBttn, "_alpha", Strong.easeOut, scrollBttn._alpha, 100, 1, true);
MoveNav = new Tween(scrollBar, "_alpha", Strong.easeOut, scrollBar._alpha, 100, 1, true);
text_mc.newsText.htmlText = BigNews[0];
text_mc.newsText.autoSize = true;
smallNews_mc.holder_mc["news_Item"+i].onRollOver = function() {
MoveNav = new Tween(smallNews_mc.holder_mc["news_Item"+[this.id]].white_mc, "_alpha", Strong.easeOut, smallNews_mc.holder_mc["news_Item"+[this.id]].white_mc._alpha, 80, 0.5, true);
};
smallNews_mc.holder_mc["news_Item"+i].onRollOut = function() {
MoveNav = new Tween(smallNews_mc.holder_mc["news_Item"+[this.id]].white_mc, "_alpha", Strong.easeOut, smallNews_mc.holder_mc["news_Item"+[this.id]].white_mc._alpha, 40, 2, true);
};
smallNews_mc.holder_mc["news_Item"+i].onRelease = function() {
_global.z = this.id;
MoveNav = new Tween(text_mc, "_alpha", Strong.easeOut, text_mc._alpha, 0, 0.5, true);
MoveNav = new Tween(scrollBar, "_alpha", Strong.easeOut, scrollBar._alpha, 0, 0.5, true);
MoveNav = new Tween(scrollBttn, "_alpha", Strong.easeOut, scrollBttn._alpha, 0, 0.5, true);
MoveNav.onMotionFinished = function() {
scrollBttn._y = 30;
text_mc._y = 30;
text_mc.newsText.htmlText = BigNews[_global.z];
text_mc.newsText.autoSize = true;
MoveNav = new Tween(scrollBttn, "_alpha", Strong.easeOut, scrollBttn._alpha, 100, 1, true);
MoveNav = new Tween(scrollBar, "_alpha", Strong.easeOut, scrollBar._alpha, 100, 1, true);
MoveNav = new Tween(text_mc, "_alpha", Strong.easeOut, text_mc._alpha, 100, 1, true);
};
};
}
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
ผลที่ได้
จากภาพตัวอย่างเมนูจะเรียงยาวไปทางด้านขวายาวจนล้น ผมต้องการขึ้นบรรนทัดใหม่ทำอย่างไงอ่ะครับช่วยหน่อยครับตันมาเป็นอาทิตย์แล้วอะครับ
*ปล. ขอบคุณทุกท่านที่เข้ามาช่วยตอบคำถามน่ะครับ
Tag : Action Script
|
|
|
|
|
|
Date :
2011-05-10 11:18:56 |
By :
ninjadark |
View :
1193 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
T.T ไม่มีใครตอบเลย
|
|
|
|
|
Date :
2011-05-10 13:46:14 |
By :
ninjadark |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|