flash actionscript:
+ - The Problem - +
I have created a simple movie that loads a line of text from and external xml
file. Featuring next and previous buttons to cycle threw the various lines of
text in the xml file.
This in it self works swimmingly. But I hit a wall when I wanted to add a
little extra functionality to the movie. When you click next or previous I want
the text to: fade out > swap the text > fade in
I set my movie up the best I know how to do this, and I get no actionscript
errors when I preview the movie.
Here is a little about what the movie DOES do:
- When you preview the movie the text loads into the box.
- When you click next/previous it waits about a second and swaps out the text,
no fadeing.
I have attached my actionscript, if someone could find an error or offer a
better solution I would much appreciate the help.
Thanks in advance,
+ - redLetter - +
p = 0;
f = 0;
beniClip._alpha = 0;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
description[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
}
firstBeni();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("beni1.xml");
/////////////////////////////////////
this.onEnterFrame = function() {
if (f == 0) {
Stop();
}
if (f == 1) {
if (beniClip._alpha>1) {
beniClip._alpha -= 10;
} else {
nextBeni();
}
}
if (f == 2) {
if (beniClip._alpha>1) {
beniClip._alpha -= 10;
} else {
prevBeni();
}
}
if (f == 3) {
if (beniClip._alpha<100) {
beniClip._alpha += 10;
} else {
f = 0;
}
}
}
previous_btn.onRelease = function() {
f = 2;
}
next_btn.onRelease = function() {
f = 1;
}
function nextBeni() {
if (p<(total-1)) {
p++;
beniClip.beni_txt.text = description[p];
f = 3;
}
}
function prevBeni() {
if (p>0) {
p--;
beniClip.beni_txt.text = description[p];
f = 3;
}
}
function firstBeni() {
beniClip.beni_txt.text = description[0];
f = 3;
}