Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11

Discussione: Mouse removeListener

  1. #1

    Mouse removeListener

    ciao io creo il mio Listener

    var mouseListener:Object = new Object();
    mouseListener.onMouseMove = function() {
    tutte le azioni......

    };
    Mouse.addListener(mouseListener);

    al fotogramma successi per rimuovere il listener faccio
    Mouse.removeListener(mouseListener)

    ma non me lo rimuovere .. perchè? :master:

  2. #2

  3. #3
    tanto per sapere il procedimento è giusto?

    Ho il mio filamto principale dove carico un swf esterno in questo swf esterno metto al fotogramma 5:

    Codice PHP:

    stop
    ();
    var 
    mouseListener:Object = new Object();
    mouseListener.onMouseMove = function() {
    tutte le azioni......

    };
    Mouse.addListener(mouseListener); 
    poi quando cambio filmato al fotogramma 6:
    Mouse.removeListener(mouseListener)

    ma non mi rimuove il Listener forse devo mettere qualche target le ho provate tutte .. :master:

  4. #4
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    io inizierei con il fare un trace di mouseListener nel fotogramma 6 e capire se in quel fotogramma è visibile o no...

  5. #5
    infatti è undefined ... ma come mai non ho assegnato nessun terget .. perchè è undefined

  6. #6
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    immagino che il problema sia dovuto a qualche interferenza nel tuo script, perchè ho fatto un test e funziona perfettamente

    probabilmente il mouseListener non viene intercettato perchè è stato dichiarato dentro un oggetto o su _root e si tenta di eliminarlo da un altro oggetto

  7. #7
    questo è tutto il cod nel fotogramma 5:
    Codice PHP:
    import mx.transitions.Tween;
    import mx.transitions.easing.Regular;
    import mx.transitions.easing.Strong;
    import mx.transitions.easing.Back;
    import mx.transitions.easing.Elastic;
    import mx.transitions.easing.Bounce;
    import mx.transitions.easing.None;

    var 
    ___TWEENtop5:Tween = new Tween(body_mc"_x"Strong.easeOutbody_mc._x_root.larghessas/215false);


    var 
    tweenListener:Object = new Object();
    tweenListener.onMotionFinished = function():Void  {
        

    // INIZIO MOUSE LISTENER CHE IN BASE AL MOVIMENTO MI SPOSTA IL BODY //////////////////////////////////////////    
    var mouseListener:Object = new Object();
    mouseListener.onMouseMove = function() {
        if (
    _ymouse 330 ){
            
    fs_mc._visible false
            fds_mc
    ._visible false
            
    if (_xmouse _root.larghessas/21) {
                    
    // MUOVE MC A SX
                    
    body_mc.onEnterFrame = function () {
                    var 
    ___TWEENmouse:Tween = new Tween(this"_x"Strong.easeOutthis._x,this._x +1515false);
                    if (
    this._x >= _root.larghessas/2) {
                    
    delete this.onEnterFrame
                    }
                };
            };
            
            
            if (
    _xmouse _root.larghessas/21) {
                
    // MUOVE MC A DX
                
    body_mc.onEnterFrame = function () {
                var 
    ___TWEENmouse2:Tween = new Tween(this"_x"Strong.easeOutthis._x,this._x 1515false);
                if ( (
    this._x this._width) <= _root.larghessas/) {
                    
    delete this.onEnterFrame
                    }
                };
            };
        };
        
    // ELIMINA ENTERFRAME SE IL YMOUSE è FUORI DAL CENTRO 
        
    if (_ymouse 330 or _ymouse 100){
            
    fs_mc._visible true
            fds_mc
    ._visible true
            delete body_mc
    .onEnterFrame
        }
        
    // ELIMINA ENTERFRAME SE IL MOUSE è FERMO IN POSIZIONE CENTRALE +O-
        
    if ((_xmouse _root.larghessas/2) && (_xmouse _root.larghessas/20)){
            
    delete body_mc.onEnterFrame;
        
        }
        
    // ELIMINA ENTERFRAME SE IL MOUSE è FERMO IN POSIZIONE CENTRALE +O-
        
    if ((_xmouse _root.larghessas/2) && (_xmouse _root.larghessas/20)){
            
    delete body_mc.onEnterFrame;
        
        }
        
    };
    Mouse.addListener(mouseListener);
    // FINE MOUSE LISTENER CHE IN BASE AL MOVIMENTO MI SPOSTA IL BODY //////////////////////////////////////////
        
        


    };
    ___TWEENtop5.addListener(tweenListener); 
    non sembra dichiarato in un oggetto .. :master:

  8. #8
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    ma come no? è dichiarato dentro un'evento del tweenListener

  9. #9
    ahh.. non finirò mai di capire as... pensavo che Mouse.addListener non avesse target dunque potevo dichiararlo dove volevo e richiamarlo come volevo bouhh.. ma ora quale sarebbe il percorso per disattivare il mouseListener .. perchè mica ci sono arrivato ehh..

  10. #10
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    allora, addListener della classe Mouse è un metodo statico, perciò può essere richiamato da qualsiasi parte attraverso la sintassi già vista (Mouse.addListener())
    il "problema" è che bisogna passargli un oggetto che viene invece dichiarato in un punto della timeline che può essere ad esempio una funzione, in tal caso la "visibilità" della variabile è strettamente legata al punto di creazione e in pratica è utilizzabile solo all'interno della funzione

    ora per non stare a inseguire percorsi, ti consiglio di inizializzare il listener fuori dalla funzione e di "attaccarlo" dentro, così

    Codice PHP:
    import mx.transitions.Tween;
    import mx.transitions.easing.Regular;
    import mx.transitions.easing.Strong;
    import mx.transitions.easing.Back;
    import mx.transitions.easing.Elastic;
    import mx.transitions.easing.Bounce;
    import mx.transitions.easing.None;

    var 
    ___TWEENtop5:Tween = new Tween (body_mc"_x"Strong.easeOutbody_mc._x_root.larghessas/215false);

    // INIZIO MOUSE LISTENER CHE IN BASE AL MOVIMENTO MI SPOSTA IL BODY //////////////////////////////////////////    
    var mouseListener:Object = new Object ();
    mouseListener.onMouseMove = function () {
        if (
    _ymouse<330) {
            
    fs_mc._visible false;
            
    fds_mc._visible false;
            if (
    _xmouse<_root.larghessas/2-21) {
                
    // MUOVE MC A SX
                
    body_mc.onEnterFrame = function () {
                    var 
    ___TWEENmouse:Tween = new Tween (this"_x"Strong.easeOutthis._xthis._x+1515false);
                    if (
    this._x>=_root.larghessas/2) {
                        
    delete this.onEnterFrame;
                    }
                };
            }
            if (
    _xmouse>_root.larghessas/2+21) {
                
    // MUOVE MC A DX
                
    body_mc.onEnterFrame = function () {
                    var 
    ___TWEENmouse2:Tween = new Tween (this"_x"Strong.easeOutthis._xthis._x-1515false);
                    if ((
    this._x+this._width)<=_root.larghessas/2) {
                        
    delete this.onEnterFrame;
                    }
                };
            }
        }
        
    // ELIMINA ENTERFRAME SE IL YMOUSE è FUORI DAL CENTRO 
        
    if (_ymouse>330 or _ymouse<100) {
            
    fs_mc._visible true;
            
    fds_mc._visible true;
            
    delete body_mc.onEnterFrame;
        }
        
    // ELIMINA ENTERFRAME SE IL MOUSE è FERMO IN POSIZIONE CENTRALE +O-  
        
    if ((_xmouse>_root.larghessas/2) && (_xmouse<_root.larghessas/2+20)) {
            
    delete body_mc.onEnterFrame;
        }
        
    // ELIMINA ENTERFRAME SE IL MOUSE è FERMO IN POSIZIONE CENTRALE +O-  
        
    if ((_xmouse<_root.larghessas/2) && (_xmouse>_root.larghessas/2-20)) {
            
    delete body_mc.onEnterFrame;
        }
    };
    var 
    tweenListener:Object = new Object ();
    tweenListener.onMotionFinished = function ():Void  {
        
    Mouse.addListener (mouseListener);
        
    // FINE MOUSE LISTENER CHE IN BASE AL MOVIMENTO MI SPOSTA IL BODY //////////////////////////////////////////
    };
    ___TWEENtop5.addListener (tweenListener); 

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 © 2025 vBulletin Solutions, Inc. All rights reserved.