Beck
03-02-2003, 08:25 AM
Wah ha ha ha ha I'm BAAACK... with another "mommy, what does this do?" issue. I've never see anything like this, and wondered if anyone was bored enough to explain it to me. :cool:
eval("trailSpriteFrame" + x + " = new Image(28,36);");
the return type (I tried it) was just object. x has value ranges from 1 - 5, methinks. I dont' know if context is important to answer this one. I suppose the parameters to the Image object are the positioning for that image. I guess I'm mostly begging to know what eval's effect has on this.
I looked closer at the code, and I'm thinking context might be needed, so I'll post it. It's modified from a dynamic drive freebee, the fading cursor script, because I'm simplifying it and experimenting with it to understand it (that's ethical in this forum, right?):
Anywayz, in the header script:
<script>
var queue = new Array();
var NUM_OF_TRAIL_PARTS = 5;
for (var x = 1; x <= NUM_OF_TRAIL_PARTS; x++) {
eval("trailSpriteFrame" + x + " = new Image(28,36);");
eval("trailSpriteFrame" + x + ".src = 'trailgif" + x + ".gif';");
}
function trailSpriteObj(anID) {
this.trailSpriteID = "trailSprite" + anID;
this.imgRef = "trailSprite" + anID + "img";
this.currentFrame = 1;
this.animateTrailSprite = animateTrailSprite;
}
function animateTrailSprite() {
if (this.currentFrame < 6 ) {
eval("document['" + this.imgRef + "'].src = trailSpriteFrame" + this.currentFrame + ".src");
this.currentFrame ++;
} else {
eval('document.all.' + this.trailSpriteID + '.style.visibility = "hidden"');
}
}
function processAnim() {
for(x=0; x < NUM_OF_TRAIL_PARTS; x++)
queue[x].animateTrailSprite();
}
function MouseMove(e) {
currentObj = shuffleQueue();
eval("document.all." +currentObj+ ".style.pixelLeft=event.clientX+document.body.scrollLeft-10;");
eval("document.all." +currentObj+ ".style.pixelTop=event.clientY+document.body.scrollTop+10;");
}
function shuffleQueue() {
lastItemPos = queue.length - 1;
lastItem = queue[lastItemPos];
for (i = lastItemPos; i>0; i--) queue[i] = queue[i-1];
queue[0] = lastItem;
queue[0].currentFrame = 1;
eval('document.all.' + queue[0].trailSpriteID + '.style.visibility = "visible"');
return (queue[0].trailSpriteID);
}
function startFadeCursor() {
for(var i = 0; i < NUM_OF_TRAIL_PARTS; i++)
queue[i] = new trailSpriteObj(i+1);
window.setInterval("processAnim();",25);
}
document.onmousemove = MouseMove;
</script>
And of course, the body stuff (mostly just a bunch of images):
<body onLoad="startFadeCursor();">
<DIV id="trailSprite1" style="position:absolute; height:28px; width:36px; z-index: 100">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite1img"></DIV>
<DIV id="trailSprite2" style="position:absolute; height:28px; width:26px;z-index: 10">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite2img"></DIV>
<DIV id="trailSprite3" style="position:absolute; height:28px; width:36px;z-index: 10">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite3img"></DIV>
<DIV id="trailSprite4" style="position:absolute; height:28px; width:36px;z-index: 10">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite4img"></DIV>
<DIV id="trailSprite5" style="position:absolute; height:28px; width:36px;z-index: 10">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite5img"></DIV>
<script language="JavaScript1.2">
<!--
if (document.all && window.print)
document.body.style.cssText="overflow-x:hidden;overflow-y:scroll;";
// -->
</script>
</body>
I'd give free cookies to whoever answers first, but you'd have to live in hawaii for me to afford the trip. Any takers? ;)
eval("trailSpriteFrame" + x + " = new Image(28,36);");
the return type (I tried it) was just object. x has value ranges from 1 - 5, methinks. I dont' know if context is important to answer this one. I suppose the parameters to the Image object are the positioning for that image. I guess I'm mostly begging to know what eval's effect has on this.
I looked closer at the code, and I'm thinking context might be needed, so I'll post it. It's modified from a dynamic drive freebee, the fading cursor script, because I'm simplifying it and experimenting with it to understand it (that's ethical in this forum, right?):
Anywayz, in the header script:
<script>
var queue = new Array();
var NUM_OF_TRAIL_PARTS = 5;
for (var x = 1; x <= NUM_OF_TRAIL_PARTS; x++) {
eval("trailSpriteFrame" + x + " = new Image(28,36);");
eval("trailSpriteFrame" + x + ".src = 'trailgif" + x + ".gif';");
}
function trailSpriteObj(anID) {
this.trailSpriteID = "trailSprite" + anID;
this.imgRef = "trailSprite" + anID + "img";
this.currentFrame = 1;
this.animateTrailSprite = animateTrailSprite;
}
function animateTrailSprite() {
if (this.currentFrame < 6 ) {
eval("document['" + this.imgRef + "'].src = trailSpriteFrame" + this.currentFrame + ".src");
this.currentFrame ++;
} else {
eval('document.all.' + this.trailSpriteID + '.style.visibility = "hidden"');
}
}
function processAnim() {
for(x=0; x < NUM_OF_TRAIL_PARTS; x++)
queue[x].animateTrailSprite();
}
function MouseMove(e) {
currentObj = shuffleQueue();
eval("document.all." +currentObj+ ".style.pixelLeft=event.clientX+document.body.scrollLeft-10;");
eval("document.all." +currentObj+ ".style.pixelTop=event.clientY+document.body.scrollTop+10;");
}
function shuffleQueue() {
lastItemPos = queue.length - 1;
lastItem = queue[lastItemPos];
for (i = lastItemPos; i>0; i--) queue[i] = queue[i-1];
queue[0] = lastItem;
queue[0].currentFrame = 1;
eval('document.all.' + queue[0].trailSpriteID + '.style.visibility = "visible"');
return (queue[0].trailSpriteID);
}
function startFadeCursor() {
for(var i = 0; i < NUM_OF_TRAIL_PARTS; i++)
queue[i] = new trailSpriteObj(i+1);
window.setInterval("processAnim();",25);
}
document.onmousemove = MouseMove;
</script>
And of course, the body stuff (mostly just a bunch of images):
<body onLoad="startFadeCursor();">
<DIV id="trailSprite1" style="position:absolute; height:28px; width:36px; z-index: 100">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite1img"></DIV>
<DIV id="trailSprite2" style="position:absolute; height:28px; width:26px;z-index: 10">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite2img"></DIV>
<DIV id="trailSprite3" style="position:absolute; height:28px; width:36px;z-index: 10">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite3img"></DIV>
<DIV id="trailSprite4" style="position:absolute; height:28px; width:36px;z-index: 10">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite4img"></DIV>
<DIV id="trailSprite5" style="position:absolute; height:28px; width:36px;z-index: 10">
<img src="blanktrail.gif" height=28 width=36 border=0 name="trailSprite5img"></DIV>
<script language="JavaScript1.2">
<!--
if (document.all && window.print)
document.body.style.cssText="overflow-x:hidden;overflow-y:scroll;";
// -->
</script>
</body>
I'd give free cookies to whoever answers first, but you'd have to live in hawaii for me to afford the trip. Any takers? ;)