Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
On case image change! HELP~
Old 06-23-2009, 01:06 PM On case image change! HELP~
Junior Talker

Posts: 3
Name: Sop
Trades: 0
Ok um i am new to css, working with some code that moves a div around the html document using W(up) S(down) A(left) D(right). I want to be able to have it change the image on keypress, so when you press W is shows one image and S shows a different one..ect

HELP PLEASE,
Sop(New user )
sopwyin54 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-23-2009, 01:13 PM Re: On case image change! HELP~
Junior Talker

Posts: 3
Name: Sop
Trades: 0
Oh and the code i'm using.
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> 
 <style type="text/css">
 body {
  margin: 0px;
  padding: 0px;
 }
 #myDiv {
                         background-color: #;
  position: absolute;
  overflow: hidden;
  width: 150px;
  height: 150px;
  left: 265px;
  top: 265px;
 }
 </style>
 <script type="text/javascript">
 <!--
  var leftPos = topPos = 265;
  var speed = 5;
  function updateDiv(keyCode) {
   switch (keyCode) {
    case 65: leftPos -= (leftPos > 0) ? speed : 0; break;
    case 68: leftPos += (leftPos < 1200) ? speed : 0; break;
    case 87: topPos -= (topPos > 0) ? speed : 0; break;
    case 83: topPos += (topPos < 2680) ? speed : 0; break;
   }
   document.getElementById('myDiv').style.left = leftPos + 'px';
   document.getElementById('myDiv').style.top = topPos + 'px';
  }
  document.onkeydown = function(evt) {
   updateDiv(evt?evt.keyCode:event.keyCode);
  }
 //-->
 </script>
</head>
<body>
<div id="myDiv"><img src="H.gif" border="0"></div>
</body>
</html>

Last edited by LadynRed; 06-23-2009 at 03:36 PM..
sopwyin54 is offline
Reply With Quote
View Public Profile
 
Old 06-23-2009, 01:13 PM Re: On case image change! HELP~
Junior Talker

Posts: 3
Name: Sop
Trades: 0
forget the <textarea></textarea> tags.. thought it would actually show one.
sopwyin54 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to On case image change! HELP~
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19699 seconds with 12 queries