Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Problema con onKeyDown

  1. #1

    Problema con onKeyDown

    ciao, ho questo codice praticamente quando premo la freccia da tastiera in giù mi scorre in giù il filmato quando premo la freccia in su ma va in su il mio mc

    funziona tutto .. però io vorrei che mi facesse la funzione solamente se il tasto è premuto se rilascio il tasto non deve fare nessuna funzione .. qualche aiutino??

    Codice PHP:
    var objList = new Object();
    objList.onKeyDown = function() {
        
        
    codbottone Key.getCode()
        
    trace(Key.getCode());
        
        if (
    codbottone == 40){
            
    moveScroll("baixo");
        }
        
        if (
    codbottone == 38){
            
    moveScroll("cima");
        }

    };
    Key.addListener(objList); 
    :master:

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    la funzione moveScroll?

  3. #3
    tutto il codice
    Codice PHP:
    if (_root.altezzas 760) {
            
    this._visible false;
        } else {
            
    this._visible true;
        }
    function 
    scrollUpdate() {
        var 
    contenuto _root.tuttoilsito_mc.contenuto;
        
    barra.scrolin_mc._height _root.altezzas/5
        barra
    .frecce_mc._y barra.scrolin_mc._height/2
        
    var pxls_cont contenuto._height-this.bg._height;
        var 
    pxls_scroll this.bg._height-this.barra._height;
        var 
    alfa pxls_cont/pxls_scroll;
        var 
    vel 2;
        var 
    desty = -this.barra._y*alfa+this.hxini;
        
    desty Math.floor(desty);
        
    contenuto._y Math.floor((contenuto._y*vel+desty)/(vel+1));
    }
    function 
    starmenuScroll() {
        
    yfin this._parent.bg._height-this._height;
        
    this.startDrag(""this._x0this._xyfin);
    }
    function 
    stopScroll() {
        
    this.stopDrag();
    }
    function 
    moveScroll(dir) {
        if (
    dir == "stop") {
            
    delete controlador["onEnterFrame"];
        } else {
            var 
    barra this.barra;
            var 
    vel 4;
            if (
    dir == "cima") {
                var 
    lim 0;
                
    vel vel*-1;
            } else {
                var 
    lim this.bg._height-barra._height;
            }
        }
        
    controlador.onEnterFrame = function() {
            if (
    dir == "baixo") {
                if (
    barra._y+vel<lim) {
                    
    barra._y barra._y+vel;
                } else {
                    
    barra._y lim;
                }
            } else if (
    barra._y+vel>lim) {
                
    barra._y barra._y+vel;
            } else {
                
    barra._y lim;
            }
        };
    }
    this.hxini this._parent.contenuto._y;
    this.onEnterFrame scrollUpdate;
    this.barra.onPress starmenuScroll;
    this.barra.onRelease stopScroll;
    this.barra.onReleaseOutside stopScroll;
    this.createEmptyMovieClip("controlador"100);

    sup.onPress = function() {
        
    moveScroll("cima");
    };
    sup.onRelease inf.onRelease=function () {
        
    moveScroll("stop");
    };
    inf.onPress = function() {
        
    moveScroll("baixo");
    };
    inf.onRelease = function() {
        
    moveScroll("stop");
    };

    barra.useHandCursor true;
    sup.useHandCursor false;
    inf.useHandCursor false;
    trace("barray" +barra._y)
    // dichiaro il listener per lo scroll
    var mouseListener:Object = new Object();
    mouseListener.onMouseWheel = function(delta) {
        
    delta=delta*5
        toty 
    barra._y + (-delta)
        

        
    //rotella in giu
        
    if (delta && barra._y <= bg._height barra._height - (-delta)) {
            if (
    barra._y toty) {
            
    moveScroll("stop")
            } else {
            
    moveScroll("baixo");
            }
        }
        
        
    //rotella in su
        
    if (delta && barra._y 0) {
            if (
    barra._y toty) {
            
    moveScroll("stop")
            } else {
            
    moveScroll("cima");
            }
        }
        
        
    trace(delta)
        

    }; 
    Mouse.addListener(mouseListener);


    var 
    objList = new Object();
    objList.onKeyDown = function() {
        
        
    codbottone Key.getCode()
        
    trace(Key.getCode());
        
        if (
    codbottone == 40){
            
    moveScroll("baixo");
        }
        
        if (
    codbottone == 38){
            
    moveScroll("cima");
        }

    };
    Key.addListener(objList); 

  4. #4
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    senza modificare troppo la cosa, aggiungerei un listener all'oggetto che comanda gli eventi di Key, con onKeyUp che richiami la funzione con "stop"

    objList.onKeyUp = function() {
    moveScroll("stop");
    };

  5. #5
    ok perfetto non ci avevo pensato ... come sempre grazie...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.