PDA

View Full Version : Layer Animation on a Path Trouble



nathaliaMota
06-09-2005, 12:23 AM
1. How do I make the following script only start when you click on a link?
2. How do I make it only start when I click on a link located on another frame?

<body>

<!-- Important Notice ( Delete this after you read it ) -->
<!-- The layer used below is just a sample one to make the timeline run. -->
<!-- Delete it and paste your own layer in this place but make sure that -->
<!-- you change "sampleLayer" below and in the fifth line after the copyright message. -->
<!-- End of Notice -->

<!-- Sample Layer [Cut] -->
<div id=sampleLayer style="position:absolute; top:20px; left:15px; width:100px; height:100px; background:#EEEEEE; border: 1px solid #919191; font-family:Verdana; font-size:8pt">Sample Layer</div>
<!-- End of Sample layer -->

<script language=JavaScript>
//////////////////////////////////////////////////////////////////
// _pathGenerator v1.1 //
//////////////////////////////////////////////////////////////////
// //
// This JavaScript can be freely used as long as this message //
// stays here in the header of the script. Any modifications //
// and bugs found (and fixed) are appreciated. //
// //
// Author : Svetlin Staev w/ changes by Dynamic Drive //
// Date : 01/10/2001 //
// Email : svetlins@yahoo.com //
// Visit : http://www.dynamicdrive.com for this script //
//////////////////////////////////////////////////////////////////
var posX, posY;
var ie = document.all?1:0;
var ns = document.layers?1:0;
var dom = document.getElementById?1:0;
var dhtml = new svetLayer("sampleLayer");
var path = new Array(59,79,60,79,60,79,61,79,62,78,63,78,68,78,71,78,79,78,86,79,100,81,107,83,118,85,122,86,130,88,133,89,136,89,137,90,137,90,137,90,138,90,138,90,138,90);
var index = 0;
var trNum = 0;
function svetLayer(id)
{
this.name = dom?document.getElementById(id):ie?document.all[id]:ns?document.layers[id]:null;
if (this.name !== null)
{
this.css = (dom||ie)?this.name.style:this.name;
this.x = dom?this.css.pixelLeft:ie?parseInt(this.css.left):this.css.left;
this.y = dom?this.css.pixelTop:ie?parseInt(this.css.top):this.css.top;
this.moveTo = moveTo;
return this;
}
else alert('Your layer does not exist');
}

function moveTo(x,y)
{
if(dom||ie)
{
this.x=x;
this.y=y;
this.css.left=x;
this.css.top=y;
}
else this.css.moveTo(x,y);
}
function timeline()
{
if(trNum < (path.length-1))
{
dhtml.moveTo(path[trNum],path[trNum+1])
trNum += 2;
setTimeout('timeline()',10);
}
else trNum=0;
}
window.onload=timeline;
</script>

jscheuer1
06-09-2005, 05:16 AM
1) Get rid of this:
window.onload=timeline;Make a link on your page:
<a href="#" onclick="timeline();return false;">Start Timeline</a>2) Get rid of this:
window.onload=timeline;Make a link on your page in another frame:
<a href="#" onclick="parent.framename.timeline();return false;">Start Timeline</a>where framename is the name of the frame containing the page with the script on it.