PDA

View Full Version : Weird Image Scrolling...Please Help


mark4man
06-12-2005, 02:38 PM
People,

Can someone please take a look at this scrolling graphic (implemented via java scripting) & tell me what’s wrong with the script...or if there's a proprietary component in Dreamweaver I should have used instead?:

http://mysite.verizon.net/vze3yjbu ('http://mysite.verizon.net/vze3yjbu')

I had wanted to add a graphic of a sound wave to my new site (created in Dreamweaver MX...which will be a resource site for digital musicians when complete); & to have it scroll across the page to resemble an audio track during playback in a computer-based digital audio workstation.

I created the graphic myself; & thought I had it configured properly with an appropriate java script to scroll at just the right speed…but when I uploaded the site, the script caused it to scroll just fine…but the cursor on the page undergoes a rapid-fire toggling between the cursor arrow & the hourglass.

One java programmer tells me it’s because the cursor is switching between normal & busy…due to the fact that the code is making a server call at the same rate the script causes it to scroll.

Another told me the problem can be fixed if the coding sets up the graphic to cache.

Here's the script:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<script>
function moveBackground(x) {
var obj = document.getElementById('testy');
obj.style.backgroundPosition = ""+x+"px 0px";
setTimeout("moveBackground("+(x+1)+")",25);
}
</script>

<body onload="moveBackground(0);">

<div id="testy" style="background:url(graphic.jpg) repeat-x; height:xXpx; width:xXXpx;"> </div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~

The only thing I did (if you view my source code) was to add absolute positioning to the layer, so as to have it scroll across the page at the height & position I wanted.

Can somebody help me out, here?...I’m not a programmer…& the page is almost working...but should this have been done with Timelines or styles instead?

Thanks very much,

mark4man

kate
06-12-2005, 03:39 PM
Welcome!

I'm no programer neither but one question does the script call for double "" like in your script:

obj.style.backgroundPosition = <span style='color:red'>""</span>+x+"px 0px"; here you have no closing "" here:

<script>
function moveBackground(x) {
var obj = document.getElementById('testy');
obj.style.backgroundPosition = ""+x+"px 0px";
setTimeout("moveBackground("+(x-1)+")",25);
}
</script>
<body onload="moveBackground(0);">

Or does +"px 0px"; represent the double ""?


like Isaid i'm no programmer, more ppl will help though!

:D

dreamlynx
06-12-2005, 07:33 PM
the best bet would be to do it in flash or swishmax. In either one of those programs you can set the speed and the sounds very easily and it would be better tan just using js. Hope this helps
Dan