More choices, more fun! Get Opera 9, Free!

javascript - control actions

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

They have: 330 posts

Joined: Apr 2000

How do I control the order that objects are moved on a webpage? ie - onLoad I want the page to move a poker card from the dealer's location to the player (moving a div). The problem is the actions are all pretty close to simultaneous so it does not look good. How do I pause between cards?

Thanks.

I know this would be a lot easier in flash, but this is a challenge I want to create in html, asp, javascript.

bja888's picture

He has: 902 posts

Joined: Feb 2004

I'm glad to know someone else knows flash isnt always the answer.

To pause between finction one and function two...
This is the last line of function one:
setTimeout("functionTwo()",100);'
The second value is Ticks. 100 ticks = one second ( I think )

Another realistic visual moveing technique is what flash refers to as "ease". Where the object slows down or speds up slightly before reaching it's destination. That's alot harder to do then one line of code though.

They have: 330 posts

Joined: Apr 2000

Thank you for the help. I will try to use that and see how it turns out.

They have: 330 posts

Joined: Apr 2000

Here is a very basic version of the code that is not working properly for me.

function dealPlayers(){
for(i=0;i<=200;i++){
setTimeout("setCardLoc(p1c1,i,70)",200);
}
}

function setCardLoc(cID,nLeft,nTop){
cID.style.left = nLeft;
cID.style.top = nTop;
}

'

After 2/10 of a second the card shows up at top=70 and left=200. Shouldn't it move 200 times between the start and end of this loop waiting 2/10 of a second each time?

They have: 330 posts

Joined: Apr 2000

I figured it out... thanks

bja888's picture

He has: 902 posts

Joined: Feb 2004

Glad I could help!