Click to See Complete Forum and Search --> : populating a flash movie with multiple XML rows


padanaram
07-28-2006, 09:46 PM
I have an action script that retrieves multiple rows of data from a php script that creates xml. Each row of content is populated into the flash movie using a scroller. To see any additional rows you can click on a link and the scroller will populate the next row of content into the flash movie.

I need to modify the action script so that all the rows of content come up at the same time. I also need to put a scroll bar in the flash movie so taht the user can scroll down and see each row of content.

Can anyone help me with what I need to do?

This action script is called in fame 1.

#include "XMLbuildObj.as"
cursor_pos = 1;
max_pos = 0;
news_xml = new XML();
scroller_xml = new Object();
stored_headlines = Array();
stored_character_data = Array();
stored_image = Array();
news_xml.ignoreWhite = true;
news_xml.onLoad = function(ok) {
if (ok) {

scroller_xml = this.buildObject();
max_pos = scroller_xml.gallery.item.length;
for (var temp = 0; temp<max_pos; temp++) {
stored_headlines[temp] = scroller_xml.gallery.item[temp].headline;
stored_image[temp] = scroller_xml.gallery.item[temp].image;
stored_character_data[temp] = scroller_xml.gallery.item[temp]._value;
// trace(stored_headlines[temp]);
}
} else {
trace("Error loading xml");
}
};
news_xml.load('px_rd_img.php?tid=1');
max_pos = stored_headlines.length;
this.onEnterFrame = function() {
if (news_xml.getBytesLoaded() == news_xml.getBytesTotal()) {
delete this.onEnterFrame;
gotoAndPlay(2);
}
};
stop();

This action script is called in frame 10.

stop();
// myDate = new Date();
// myDate = (myDate.getMonth()+"/"+myDate.getDate()+"/"+(myDate.getFullYear()));
// for (temp=0; temp<200; temp++) {
// stored_headlines[temp] = myDate+" Headline "+(temp+1);
// }
Key.addListener(this);
function easeToX(mc, locX, passes) {
if (Math.abs(locX-mc._x)<=1) {
mc._x = locX;
}
if (mc._x != locX) {
spX = mc._x;
difX = (locX-spX);
xStp = difX/passes;
// 6 is best
mc._x = spX+xStp;
return false;
} else {
return true;
}
}
function easeToY(mc, locY, passes) {
if (Math.abs(locY-mc._y)<1) {
mc._y = locY;
}
if (mc._y != locY) {
spY = mc._y;
difY = (locY-spY);
yStp = difY/passes;
// 6 is best
mc._y = spY+yStp;
return false;
} else {
return true;
}
}
function theLoop(firstTime) {
cursor_pos_temp = cursor_pos;
for (i=0; i<max_pos; i++) {
if (firstTime) {
attachMovie("headlineclip", "headclip"+i, i);
this["headclip"+i]._x = 0;
}
this["headclip"+i]._y = 100+this["headclip"+i]._height*i;
this["headclip"+i].headline = stored_headlines[i];
this["headclip"+i].headline_id = i+1;
this["headclip"+i]._visible = true;
}
for (i=0; i<max_pos; i++) {
if (firstTime) {
newsframe.nfContent.attachMovie("News Mask Description", "description"+i, i);
newsframe.nfContent["description"+i]._x = 0;
}
newsframe.nfContent["description"+i]._y = newsframe.nfContent["description"+i]._height*i;
newsframe.nfContent["description"+i].headline = stored_headlines[i];
newsframe.nfContent["description"+i].description.htmlText = stored_character_data[i].split('<a ').join('<font color=\"#A16340\"><u><a ').split('</a>').join('</a></u></font>');
newsframe.nfContent["description"+i].image = stored_image[i];
}
}
theLoop(1);
highestdepth = this.getNextHighestDepth();
newsframe.swapDepths(highestdepth);
this.onEnterFrame = function() {
// trace(this["headclip0"]._height)
// trace("x: " + _xmouse +",y: " + _ymouse);
counter = cursor_pos+" / "+max_pos;
cursor_pos_temp = cursor_pos;
easeToY(newsframe.nfContent, newsframe.nfContent.description0._height-cursor_pos_temp*newsframe.nfContent.description0._height, 2);
if (Key.isDown(Key.UP)) {
if (cursor_pos<max_pos) {
cursor_pos++;
}
newsframe.nfContent._y++;
}
if (Key.isDown(Key.DOWN)) {
if (cursor_pos>1) {
cursor_pos--;
}
newsframe.nfContent._y--;
}
for (i=0; i<cursor_pos; i++) {
if (this["headclip"+i]._y>Math.round((cursor_pos-i)*-(this["headclip"+i]._height)-(this["headclip"+i]._height)*3)) {
m = easeToY(this["headclip"+i], (this["headclip"+i]._height*5)+(cursor_pos-i)*-(this["headclip"+i]._height)-(this["headclip"+i]._height)*3, 6);
}
if (this["headclip"+i]._y<-this["headclip"+i]._height || (this["headclip"+i]._y>=this["headclip"+i]._height/2 && this["headclip"+i]._y<=this["headclip"+i]._height*8)) {
this["headclip"+i]._visible = false;
} else {
this["headclip"+i]._visible = true;
}
}
for (k=cursor_pos; k<max_pos; k++) {
m = easeToY(this["headclip"+k], (this["headclip"+k]._height)*18+(cursor_pos-k)*-(this["headclip"+k]._height), 6);
if (this["headclip"+k]._y>(this["headclip"+k]._height)*20) {
this["headclip"+k]._visible = false;
} else {
this["headclip"+k]._visible = true;
}
}
};