Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2005, 11:10 AM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default JavaScript & Flash

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>


 
Old September 6th, 2005, 05:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
Default

The script at that page doesn't work for me. In IE6 I get:

Line: 90
Error: Out of memory

and then:
Out of memory at line 0

Doesn't workie in Moz either.

--
http://yupapa.com
 
Old September 6th, 2005, 10:18 AM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by meow
 The script at that page doesn't work for me. In IE6 I get:

Line: 90
Error: Out of memory

and then:
Out of memory at line 0

Doesn't workie in Moz either.

--
http://yupapa.com
I have already worked this problem out, but if you just want to view it working try:

http://www.novastaramerica.com/ctrlTemp/jsonly6.aspx






Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash & SQL Adam H-W Flash (all versions) 4 December 22nd, 2006 07:45 PM
Flash and Javascript (VERY URGENT) Apocolypse2005 Javascript 3 July 2nd, 2006 02:12 PM
flash & c# titto_oo7 C# 1 April 29th, 2006 02:41 PM
Javascript && keeps turnig into &amp;&amp; ayrton Pro VB.NET 2002/2003 3 June 27th, 2005 03:34 PM
calling javascript from flash Adam H-W Flash (all versions) 2 March 17th, 2004 11:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.