Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2004
    Messaggi
    32

    Posizionamento del codice e kf

    Sulla stessa scena ho un mc che contiene una cartina e 4 pulsanti: su, giù, dx e sx.
    Al pulsante di dx ho dato questo codice:

    on (press) {
    var dx = true;
    trace(dx);
    }
    on (release) {
    var dx = false;
    trace(dx);
    }

    e al pulsante di sx, questo:
    on (press) {
    var sx = true;
    trace(sx);
    }
    on (release) {
    var sx = false;
    trace(sx);
    }

    al fotogramma in cui è presente questo

    target_item.onEnterFrame = function() {
    trace (sx);
    if (sx == true) {
    speed = 10;
    this._x += -speed;
    }
    };
    target_item.onEnterFrame = function() {
    trace (dx);
    if (dx == true) {
    speed = 10;
    this._x -= -speed;
    }
    };
    target_item.onEnterFrame = function() {
    trace (gx);
    if (gx == true) {
    speed = 10;
    this._y += -speed;
    }
    };
    target_item.onEnterFrame = function() {
    trace (sux);
    if (sux == true) {
    speed = 10;
    this._y += -speed;
    }
    };

    Ho notato che esegue il codice relativo al pulsante su, l'ultimo in sequenza nel codice, il precedente codice viene ignorato.
    Se sposto il codice relativo al pulsante di destra all'ultimo posto in sequenza esegue correttamente il pulsante di destra, ecc.
    Qual è il modo corretto di applicare il quel codice?
    Ho provato a inserire, dividendolo, il codice in kf differenti ma non funziona... c'è sempre il problema dell'ordine di sequenza dei kf in cui è posizionato il codice.
    es. http://www.ge.camcom.it/tipici/prove tipici.swf
    Help
    Grazie

  2. #2
    Utente bannato
    Registrato dal
    Jul 2006
    Messaggi
    605
    Il link che hai postato è inesistente...


    comunque prova così:

    on (press) {
    dx = true;
    }
    on (release, releaseOutside) {
    dx = false;
    }

    e al pulsante di sx, questo:
    on (press) {
    sx = true;
    }
    on (release, releaseOutside) {
    sx = false;
    }


    al fotogramma in cui è presente questo

    target_item.onEnterFrame = function() {
    if (sx == true) {
    speed = 10;
    this._x += -speed;
    }
    if (dx == true) {
    speed = 10;
    this._x -= -speed;
    }
    if (gx == true) {
    speed = 10;
    this._y += -speed;
    }
    if (sux == true) {
    speed = 10;
    this._y += -speed;
    }
    };

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.