Closed Thread Icon

Topic awaiting preservation: Timing Rollover Animations (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8790" title="Pages that link to Topic awaiting preservation: Timing Rollover Animations (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Timing Rollover Animations <span class="small">(Page 1 of 1)</span>\

 
Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 07-30-2003 16:08

http://www.twistedport.com/misc/rollproblems/

I have no real problem with my rollovers. but now I want to negotiate the simple matter of waiting a little while before executing them.

You'll notice nothing happens... no error screen, no bad line numbers, nothing... I've been fighting with this for days and I've googled my way out of resources..

This is the 'offending code' (Bad code!! Bad!!)...

code:
function waittrade(name,on,off,delayon,delayoff){
//alert("Name:"+name+", numbers-"+on+","+off+","+delayon+","+delayoff+"");
setTimeout("document.images[\'"+name+"\'].src = pics["+on+"].src","+delayon+");
setTimeout("document.images[\'"+name+"\'].src = pics["+off+"].src","+delayoff+");

//setTimeout("trade(\'"+name+"\',"+on+")","+delayon+");
//setTimeout("trade(\'"+name+"\',"+off+")","+delayoff+");
}


.. and I call it like this-
waittrade('kappa',1,0,10,5000);

What, exactly, am I doing wrong?


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 07-30-2003 16:25

PS: I suspect a lot of your questions can be answered by looking on some of the threads here or following some of the links:

:FAQ: How do I dynamically swap images?

___________________
Emps

FAQs: Emperor

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 07-30-2003 16:32

*gasp*
it worked when I did this:
setTimeout('document.kappa.src = pics[1].src',500);
setTimeout('document.kappa.src = pics[0].src',5000);


why's that?

*damn*
but it broke again with this:
setTimeout('document.'+name+'.src = pics['+on+'].src','+delayon+');
setTimeout('document.'+name+'.src = pics['+off+'].src','+delayoff+');


how can I pass arguments into the setTimeouts?


[This message has been edited by Petskull (edited 07-30-2003).]

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 07-30-2003 17:06

Petskull: you made a typo, remove the quotes around the delay, like this

code:
setTimeout('document.'+name+'.src = pics['+on+'].src', delayon );
setTimeout('document.'+name+'.src = pics['+off+'].src', delayoff );

Now it should work.

Cheers,

Mathieu "POÏ" HENRI

[This message has been edited by poi (edited 07-30-2003).]

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 07-30-2003 20:04

wow, poi- with a little modification, that worked beautifully!!

Here's what I ended up with-
function waittrade(name,on,off,delayon,delayoff){
//alert("Name:"+name+", numbers-"+on+","+off+","+delayon+","+delayoff+"");
setTimeout('trade(\''+name+'\','+on+')',delayon);
setTimeout('trade(\''+name+'\','+off+')',delayoff);
}


Thx!

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 07-31-2003 10:16

That was just a typo. You script can be handy for navigations bars.
Since you make multiple calls to the waittrade function, let me suggest to handle any number of arguments:

code:
function waittrade( )
// waittrade( name0, state0, delay0 [, name1, state1, delay1 [, nameN, stateN, delayN ]] )
{
var i = 0,
arguments = waittrade.arguments
while( i<=arguments.length-3 )
setTimeout( 'trade("'+ arguments[ i++ ] +'",'+ arguments[ i++ ] +')', arguments[ i++ ] );
}
// examples of use
waittrade( "tot",1,150, "pouet",3,700, "gerard",0,1000 )
waittrade( 'gamma',0,0, 'kappa',1,100, 'lamba',1,200, 'theta',1,300, 'kappa',0,200, 'lamba',0,300, 'theta',0,400 )

Further improvements could be done to tackle special cases where you wish to set several images to the same state at the same time. To do so, you could replace the name argument by a list of names joined by a space / semicolon / smurf / ... and split it once in the trade function to process every single image

Hope that helps.

Mathieu "POÏ" HENRI

[This message has been edited by poi (edited 07-31-2003).]

Petskull
Maniac (V) Mad Scientist

From: 127 Halcyon Road, Marenia, Atlantis
Insane since: Aug 2000

posted posted 08-05-2003 15:15

whoa!! that is so fucking cool!!!!!

It hadn't crossed my mind to do it that way!!!


Code - CGI - links - DHTML - Javascript - Perl - programming - Magic - http://www.twistedport.com
ICQ: 67751342

« BackwardsOnwards »

Show Forum Drop Down Menu