Noobie Problem with Event and Animation

Hi,

i'm having a little problem here. I created a class called predictableElement that is controlled by two events, if the first one happens, it calls the method OpenRoad, and the box have an animation, and if you call the second one, the box will have the opposite animation. The problem is, each time i call the event the speed of the box increases, i dont know why. This is my code:





import com.jme.animation.SpatialTransformer;

import com.jme.bounding.BoundingBox;

import com.jme.image.Texture;

import com.jme.math.Vector3f;

import com.jme.scene.shape.Box;

import com.jme.scene.state.TextureState;

import com.jme.system.DisplaySystem;

import com.jme.util.TextureManager;





import java.net.URL;





public class predictableElement extends Box{



SpatialTransformer stController;



/** Create an predictableElement that will randomly open and close the street */

public predictableElement()

{

super("predictableElement", new Vector3f(0, -7, 0), new Vector3f(2, -6, 1));



this.setModelBound(new BoundingBox());

        this.updateModelBound();

       

        URL URLBlockadePicture = predictableElement.class.getClassLoader().getResource("img/cancela.JPG");

        TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();

        Texture t=TextureManager.loadTexture(URLBlockadePicture, Texture.MM_LINEAR, Texture.FM_LINEAR);

        ts.setTexture(t);

        this.setRenderState(ts);

       

        stController = new SpatialTransformer(1);

       

}



public void BlockRoad()

{

    stController.setObject(this, 0, -1);

    stController.setPosition(0, 0, new Vector3f(0, 0, 0));

    stController.setPosition(0, 50, new Vector3f(9 , 0, 0));

    stController.interpolateMissing();

    this.addController(stController);

}



public void UnblockRoad()

{

    stController.setObject(this, 0, -1);

    stController.setPosition(0, 0, new Vector3f(9 , 0, 0));

    stController.setPosition(0, 50, new Vector3f(0 , 0, 0));

    stController.interpolateMissing();

    this.addController(stController);

}





}

















import com.jme.app.SimpleGame;

import com.jme.input.KeyBindingManager;

import com.jme.input.KeyInput;

import com.jme.scene.state.LightState;

import com.jme.scene.Node;







public class teste extends SimpleGame{





predictableElement cancela;



boolean teste = false;





    public static void main(String[] args) {

        teste app=new teste();    // Create Object

        app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);

        // Signal to show properties dialog

        app.start();    // Start the program

    }

protected void simpleInitGame(){



        cancela = new predictableElement();

       



       

        rootNode.attachChild(cancela);

        rootNode.setLightCombineMode(LightState.OFF);

       

       

       

       

        KeyBindingManager.getKeyBindingManager().set(

                "CancelaAbre",

                KeyInput.KEY_C);

        KeyBindingManager.getKeyBindingManager().set(

                "CancelaFecha",

                KeyInput.KEY_M);

       

}











protected void simpleUpdate(){

try {

Thread.sleep(5);

} catch (InterruptedException e) {

}





if (KeyBindingManager.getKeyBindingManager().isValidCommand("CancelaAbre",true)){

if (teste){

cancela.UnblockRoad();

teste=false;

}

}

if (KeyBindingManager.getKeyBindingManager().isValidCommand("CancelaFecha",true)){

if (!(teste)){

cancela.BlockRoad();

teste = true;

}

}

}

}









i would be very glad if someone could help me!

to see the problem stay tapping M, C, M, C a lot of times, and you will see that the speed increases a lot