I have a script that will rotate Flash Movies based on a timer(when the timer reaches 0 it shows the next movie). The script get the movie rotation from a XML file. There are also two buttons that will move to the next or previous movies. This script is working as it should.
The problem is when the timer reaches 0 and the script moves to the next movie I get a flicker(the space where the movie is rendered goes all white, I suppose while the next movie is loading). Can someone show/tell me how I can get rid of this effect? I am new to javascript all help is appreciated.
Here is a link of this script working:
http://www.novastaramerica.com/ctrlTemp/jsonly5.aspx
this is just a simpleflash movie in different colors to show the rotation.
Here is the script:
<%@ Page Language="
VB" %>
<script runat="server">
' Insert page code here
'
</script>
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
var c = 0
var j = 0
var b = 3
var x
var count
var secs
var timerID = null
var timerRunning = false
var delay = 1000
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = flsString;
c++;
b = 7;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = function () {if (xmlDoc.readyState == 4) flsString()};
}
else
{
alert('Your browser can\'t handle this script');
return;
}
xmlDoc.load("../ctrlTemp/xml/intAd/intFlsAdSysblk.xml");
}
function flsString()
{
x = xmlDoc.getElementsByTagName('Ad');
count = (x.length - 1);
var run = x[j].childNodes[b].firstChild.nodeValue;
if (run == 'Run')
{
var flsStr = '<embed src=' + x[j].childNodes[c].firstChild.nodeValue + '>';
flsStr += '<' + '/' + 'EMBED>';
document.getElementById("jb").innerHTML = (flsStr);
InitializeTimer()
}
else
{
chgAd()
}
}
function InitializeTimer()
{
// Set the length of the timer, in seconds
secs = 50
StopTheClock()
StartTheTimer()
}
function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}
function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
chgAd()
}
else
{
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}
function chgAd()
{
count = (x.length - 1);
if (j < count)
{
j = j + 1
flsString()
}
else if (j = count)
{
j = 0
flsString()
}
}
function backAd()
{
if (j < count && j > 0)
{
j = j - 1
flsString()
}
else if (j == count)
{
j = j - 1
flsString()
}
else if (j == 0)
{
j = count
flsString()
}
}
// -->
</script>
</head>
<body onload="importXML()">
<form runat="server">
<Div id="jb"></Div>
<input id="button2" onclick="backAd()" type="button" value="Prev Ad" />
<input id="button1" onclick="chgAd()" type="button" value="Next Ad" />
</form>
</body>
</html>