Mod Adk Portal (2.1.1)

Adk portal is a portal integrated to SMF, with multiple extensions and features.
The portal is aimed at simple and intuitive to the Administrator.
It has all the characteristics of portal, in addition to having a great set of downloads, system of internal pages, etc.

Mod Adk Seo (3.0)

Adk Seo is an internal system of SMF to improve your ranking.
It has powerful features to appear on the top of major search engines.
With this product, you can change your urls, choose your format, encouraging social activity on your site, place their own sitemaps, etc.
Mod Adk Blog (3.0)

Adk blog is an internal system of SMF to help encourage business users.
This product will create a space where your users can use as your own blog, creating categories, entries, and managing your comments.


Movimiento básico de imagenes en Javascript


Board:

Tutoriales para tu Web

Topic:

Movimiento básico de imagenes en Javascript


Description:

Tutoriales que no tengan que ver con smf, sino para tu web.

Author Topic: Movimiento básico de imagenes en Javascript  (Read 2136 times)

0 Members and 1 Guest are viewing this topic.

Movimiento básico de imagenes en Javascript

Movimiento básico de imagenes en Javascript
« on: September 25, 2010, 11:31:58 PM »
Hello darling, i'm back home! :P

Movimiento básico de imagenes en Javascript

Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">
  <head>
<title>Hello</title>
<!------------SMFPERSONAL.NET------------>
<script type="text/javascript">
x= 10; //Eje X
y= 10; //Eje Y
function Move(dir)
{
switch (dir.keyCode)
{
//Up
case 38:
y-= 25;
document.getElementById("imagen").style.top= String(y) + "px";
break;
//Down
case 40:
y+= 25;
document.getElementById("imagen").style.top= String(y) + "px";
break;
//Right
case 39:
x+= 25;
document.getElementById("imagen").style.left= String(x) + "px";
break;
//Left
case 37:
x-= 25;
document.getElementById("imagen").style.left= String(x) + "px";
break;
}
}
</script>
  </head>
<body onkeyup="Move(event);">
<img src="Image.png" id="imagen" style="position: relative;" alt="dfdf"/>
</body>
</html>

¿Como funciona?

- Colocamos la imagen en un lugar especifico:
Quote
x= 10; //Left
y= 10; //Top

- Creamos una funcion que lea e interprete los movimientos de las teclas..
Quote
switch (dir.keyCode)
            {}

- Tenemos que saber cual numero corresponde a cada tecla:
Quote
37: izquierda
38: arriba
39: abajo
40: derecha

- Insertamos los valores que vamos a usar, si queremos movernos hacia arriba lo haremos sobre el Eje Y:
Quote
y+= 25;
Si es negativo vamos hacia abajo...
Quote
y-= 25;
Confirmamos que usamos el eje Y:
Quote
style.top
Pero si usamos el X:
Quote
style.left

- Lo hacemos funcionar...
Quote
= String(y) + "px";
El string que usamos es la variable que hemos definido hace un segundo: "Y+=..." y como siempre usamos medidas en  PX, no CM, no MM, no KM: Pixels

- Por último:
Preparamos al BODY para que utilize nuestro JS ;)

Quote
<body onkeyup="Move(event);">
      <img src="Image.png" id="imagen" style="position: relative;" alt="dfdf"/>
   </body>

Este código mueve una imagen, pude ser un DIV, uan tabla, lo que quieras, editalo a tu gusto :D


Espero que les sirva, dejen comentarios y dudas, Saludos!

Descargalo: http://www.smfpersonal.net/downloads.html;sa=view;down=173

Snailx

  • Newbie
  • *
  • Posts: 35



Sorry visitor. To access the SMF Personal answers, you need to Register or Login.

Atte. SMF Personal

Tags

 


 
Application Parser To Mod

It is a system developed by SMF Personal, similar to parse smf, but with the difference that it not only show us the steps to install mods but also show us the steps to uninstall and update mods.
The mods that can be analyzed are obviously those who are raised in SMF Personal.
Section Mods

In this section you will find all mods done by the staff and users of SMF Personal.
The mods are displayed in a simple and easy to read.
Section Tutorials

In this section you will find all the tutorials made by our staff and users of SMF Personal.
The tutorials are displayed in a simple and easy to read.

SMF 2.0.2 | SMF © 2011, Simple Machines | Adk Portal 2.1.1 © SMF personal  & Adk Seo 3.0
This site is not affiliated with or endorsed by Simple Machines