Foros del Web » Creando para Internet » Flash y Actionscript »

Evitar que se mueva el scroll con las flechas

Estas en el tema de Evitar que se mueva el scroll con las flechas en el foro de Flash y Actionscript en Foros del Web. Hola, Tengo un juego flash y cuando apretas haci arriba en ie se mueve haci arriba, cuado apretas hacia abajo se mueve hacia abajo Como ...
  #1 (permalink)  
Antiguo 24/05/2009, 19:34
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Evitar que se mueva el scroll con las flechas

Hola,
Tengo un juego flash y cuando apretas haci arriba en ie se mueve haci arriba, cuado apretas hacia abajo se mueve hacia abajo
Como evitar eso
Gracias
Salu2
__________________
Half Music - www.halfmusic.com
  #2 (permalink)  
Antiguo 26/05/2009, 12:54
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Evitar que se mueva el scroll con las flechas

Nadie sabe
__________________
Half Music - www.halfmusic.com
  #3 (permalink)  
Antiguo 26/05/2009, 13:19
Avatar de highlord  
Fecha de Ingreso: noviembre-2007
Ubicación: Argentina
Mensajes: 353
Antigüedad: 16 años, 4 meses
Puntos: 16
Respuesta: Evitar que se mueva el scroll con las flechas

El scroll de cualquier navegador se mueve con las flechas, hasta que no des un clic en tu pelicula o juego para de alguna forma activarlo las flechas estarán controlando el scroll del navegador, no puedes evitar eso, por ahi lo que te falta en el juego son los controles para ordenar el movimiento con las flechas por lo que estas siguen respondiendo a la función del navegador.
  #4 (permalink)  
Antiguo 26/05/2009, 14:01
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Evitar que se mueva el scroll con las flechas

Pero el problema es solo en IE, en todos los otros navegadores anda bien
__________________
Half Music - www.halfmusic.com
  #5 (permalink)  
Antiguo 26/05/2009, 14:16
Avatar de highlord  
Fecha de Ingreso: noviembre-2007
Ubicación: Argentina
Mensajes: 353
Antigüedad: 16 años, 4 meses
Puntos: 16
Respuesta: Evitar que se mueva el scroll con las flechas

no es una sorpresa no!!!!!!

Muchos problemas como este encontrarás en Internet Explorer.

Deberíamos hacer una lista de problemas de publicación de Flash en Int. Explorer.
porque cada vez son más y más insólitos.

Pleace no Utilicen IE.

Muerte a I.Explorer!!!!
jaja

vean esta página utilizando Int. Explorer y sabrán de lo que estoy hablando.

http://crea-flash.com/

Saludos!!!!
  #6 (permalink)  
Antiguo 26/05/2009, 14:29
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Evitar que se mueva el scroll con las flechas

Si jejjejje, tambien tengo problemas con ie en javascript
¿pero como puedo resolver el problema?,
es que es de un juego en facebook y cada ves resivo mas contactos por eso y e visto juegos que tuvieron el mismo problema y ya lo repararon y vi su codigo y no modificaron nada de html (algunos).
Gracias
Salu2
__________________
Half Music - www.halfmusic.com
  #7 (permalink)  
Antiguo 26/05/2009, 14:46
Avatar de highlord  
Fecha de Ingreso: noviembre-2007
Ubicación: Argentina
Mensajes: 353
Antigüedad: 16 años, 4 meses
Puntos: 16
Respuesta: Evitar que se mueva el scroll con las flechas

puedes pasar el código???

Si es AS2 te ayudo.
  #8 (permalink)  
Antiguo 26/05/2009, 21:08
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Evitar que se mueva el scroll con las flechas

Este es todo el codigo:
Código actionscript:
Ver original
  1. stop();
  2. // Snake Game by Strille, 2004, www.strille.net
  3.  
  4. blockSize = 15;   // the block width/height in number of pixels
  5. gameHeight = 16; // the game height in number of blocks
  6. gameWidth  = 33; // the game width in number of blocks
  7. SNAKE_BLOCK = 15; // holds the number used to mark snake blocks in the map
  8. SCORE_X_BLOCK = 40;
  9. score = 0; // keeps track of the score
  10. snakeBlockCounter = 3; // keeps track of the snake blocks, increased on every frame
  11. foodCounter = 0;
  12. snakeEraseCounter = -1; // increased on every frame, erases the snake tail (setting this to -3 will result in a 3 block long snake at the beginning)
  13. VIDAS = 3;
  14. vida.gotoAndStop('v3');
  15.  
  16. keyListener = new Object(); // key listener
  17. keyListener.onKeyDown = function() {
  18.     var keyCode = Key.getCode(); // get key code
  19.    
  20.     if (keyCode > 36 && keyCode < 41) { // arrow keys pressed (37 = left, 38 = up, 39 = right, 40 = down)...
  21.         if (game.onEnterFrame != undefined) { // only allow moves if the game is running, and is not paused
  22.             if (keyCode-37 != turnQueue[0]) { // ...and it's different from the last key pressed
  23.                 turnQueue.unshift(keyCode-37); // save the key (or rather direction) in the turnQueue
  24.             }
  25.         }
  26.     } else if (keyCode == 32) { // start the game if it's not started (32 = SPACE)
  27.         if (!gameRunning) {
  28.             startGame();
  29.         }
  30.     } else if (keyCode == 80) { // pause/unpause (80 = 'P')
  31.         if (gameRunning) {
  32.             if (game.onEnterFrame) { // pause
  33.                 delete game.onEnterFrame; // remove main loop
  34.                 textMC.gotoAndStop("paused");
  35.             } else { // exit pause mode
  36.                 game.onEnterFrame = main; // start main loop
  37.                 textMC.gotoAndStop("hide");
  38.             }
  39.         }
  40.     }
  41. };
  42. Key.addListener(keyListener);
  43.  
  44. if (!gameRunning) {
  45.     startGame();
  46. }
  47.  
  48.  
  49. function startGame() {
  50.     x = int(gameWidth/2); // x start position in the middle
  51.     y = gameHeight-2;     // y start position near the bottom
  52.    
  53.     xVelocity = [-1, 0, 1, 0]; // x velocity when moving left, up, right, down
  54.     yVelocity = [0, -1, 0, 1]; // y velocity when moving left, up, right, down
  55.    
  56.     map = new Array(); // create an array to store food and snake
  57.     for (var n=0;n<gameWidth;n++) { // make map a 2 dimensional array
  58.         map[n] = new Array();
  59.     }
  60.  
  61.     turnQueue = new Array(); // a queue to store key presses (so that x number of key presses during one frame are spread over x number of frames)
  62.    
  63.     game.createEmptyMovieClip("food", 1); // create MC to store the food
  64.     game.createEmptyMovieClip("s", 2); // create MC to store the snake
  65.    
  66.  
  67.    
  68.     currentDirection = 1; // holds the direction of movement (0 = left, 1 = up, 2 = right, 3 = down)
  69.    
  70.     if(VIDAS<=0){
  71.         score = 0; // keeps track of the score
  72.         snakeBlockCounter = 3; // keeps track of the snake blocks, increased on every frame
  73.         foodCounter = 0;
  74.         snakeEraseCounter = -1; // increased on every frame, erases the snake tail (setting this to -3 will result in a 3 block long snake at the beginning)
  75.         VIDAS = 3;
  76.         vida.gotoAndStop('v3');
  77.     }
  78.     scoreTextField.text = "Puntos: "+score+" | Vidas: "+VIDAS; // type out score info
  79.     placeFood("new"); // place a new food block
  80.        
  81.    
  82.     textMC.gotoAndStop("hide"); // make sure no text is visible (like "game over ")
  83.     game.onEnterFrame = main; // start the main loop
  84.     gameRunning = true; // flag telling if the game is running. If true it does not necessarily mean that main is called (the game could be paused)
  85. }
  86.  
  87.  
  88. function main() { // called on every frame if the game is running and it's not paused
  89.     if (turnQueue.length > 0) { // if we have a turn to perform...
  90.         var dir = turnQueue.pop(); // ...pick the next turn in the queue...
  91.         if (dir &#37; 2 != currentDirection % 2) { // not a 180 degree turn (annoying to be able to turn into the snake with one key press)
  92.             currentDirection = dir; // change current direction to the new value
  93.         }
  94.     }
  95.    
  96.     x += xVelocity[currentDirection]; // move the snake position in x
  97.     y += yVelocity[currentDirection]; // move the snake position in y
  98.    
  99.     if (map[x][y] != SNAKE_BLOCK && x > -1 && x < gameWidth && y > -1 && y < gameHeight) { // make sure we are not hitting the snake or leaving the game area
  100.         game.s.attachMovie("snakeMC", snakeBlockCounter, snakeBlockCounter, {_x: x*blockSize, _y: y*blockSize}); // attach a snake block movie clip
  101.         snakeBlockCounter++; // increase the snake counter
  102.    
  103.         if (typeof(map[x][y]) == "movieclip") { // if it's a not a vacant block then there is a food block on the position
  104.             score += SCORE_X_BLOCK; // add points to score
  105.             scoreTextField.text = "Puntos: "+score+" | Vidas: "+VIDAS; // type out score info
  106.             snakeEraseCounter -= 1; // make the snake not remove the tail for five loops
  107.             placeFood(map[x][y]); // place the food movie clip which is referenced in the map map[x][y]
  108.         }
  109.        
  110.         map[x][y] = SNAKE_BLOCK; // set current position to occupied
  111.    
  112.         var tailMC = game.s[snakeEraseCounter]; // get "last" MC according to snakeEraseCounter (may not exist)
  113.         if (tailMC) { // if the snake block exists
  114.             delete map[tailMC._x/blockSize][tailMC._y/blockSize]; // delete the value in the array m
  115.             tailMC.removeMovieClip(); // delete the MC
  116.         }
  117.         snakeEraseCounter++; // increase erase snake counter   
  118.     } else { // GAME OVER if it is on a snake block or outside of the map
  119.         gameOver();
  120.     }
  121. }
  122.  
  123.  
  124. function gameOver() {
  125.     VIDAS--;
  126.     if(VIDAS<=0){
  127.         textMC.gotoAndStop("gameOver"); // show "game over" text
  128.     }else{
  129.         textMC.gotoAndStop("vidamenos");
  130.         vida.gotoAndPlay('v'+VIDAS);
  131.     }
  132.     delete game.onEnterFrame; // quit looping main function
  133.     gameRunning = false; // the game is no longer running
  134.    
  135. }
  136.  
  137.  
  138. function placeFood(foodMC) {
  139.     do {
  140.         var xFood = random(gameWidth);
  141.         var yFood = random(gameHeight);
  142.     } while (map[xFood][yFood]); // keep picking a spot until it's a vacant spot (we don't want to place the food on a position occupied by the snake)
  143.    
  144.     if (foodMC == "new") { // create a new food movie clip
  145.         foodMC = game.food.attachMovie("foodMC", foodCounter, foodCounter);
  146.         foodCounter++;
  147.     }
  148.    
  149.     foodMC._x = xFood*blockSize; // place the food
  150.     foodMC._y = yFood*blockSize; // place the food
  151.    
  152.     map[xFood][yFood] = foodMC; // save a reference to this food movie clip in the map
  153. }
Gracias
Salu2
__________________
Half Music - www.halfmusic.com
  #9 (permalink)  
Antiguo 27/05/2009, 22:02
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Evitar que se mueva el scroll con las flechas

Nadie sabe
__________________
Half Music - www.halfmusic.com
  #10 (permalink)  
Antiguo 28/05/2009, 15:55
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Evitar que se mueva el scroll con las flechas

Ayuda por favor!
__________________
Half Music - www.halfmusic.com
  #11 (permalink)  
Antiguo 30/05/2009, 12:17
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Evitar que se mueva el scroll con las flechas

Ayuda por favor!
__________________
Half Music - www.halfmusic.com
  #12 (permalink)  
Antiguo 08/06/2009, 18:17
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Evitar que se mueva el scroll con las flechas

nadie por favor!
__________________
Half Music - www.halfmusic.com
  #13 (permalink)  
Antiguo 09/06/2009, 14:00
Avatar de pato12  
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 6 meses
Puntos: 101
Respuesta: Evitar que se mueva el scroll con las flechas

Hola,
Descubri que es problema del codigo HTML. Este es mi codigo:
Código html:
Ver original
  1. <div id="XXX" height="313" width="500" overflow="hidden" class="XXX"><embed type="application/x-shockwave-flash" src="http://www.miweb.com/juego.swf" style="" id="XXX" name="XXX" bgcolor="000000" quality="high" allowscriptaccess="never" fbjs="XXX" wmode="transparent" flashvars="XXX" width="500" height="313"></div>  </p>
y no puede casi cambiarlo porque uso ftml (html de facebook)
alguien sabe como puedo solucionarlo.
Gracias
Salu2
__________________
Half Music - www.halfmusic.com
  #14 (permalink)  
Antiguo 09/08/2009, 12:28
 
Fecha de Ingreso: agosto-2009
Mensajes: 3
Antigüedad: 14 años, 8 meses
Puntos: 0
Respuesta: Evitar que se mueva el scroll con las flechas

Ya encontre la solucion a este problema del scroll en flash/facebook
hay que agregar el wmode = "window"
yo lo tenia en transparent y lo cambie a window y ahora cuando juego ya no se mueve el scroll del maldito explorer!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:14.