Muzzleflash ParticleEmitter problem

Im trying to make a muzzleflash for a gun using particle effects, but I cant figure out how to make a particle emitter appear for a certain time period.

I tried java.util.timer:

muzzleTimer.schedule(

new TimerTask()

{

public void run()

{

muzzleFlash.setNumParticles(1);

try{

Thread.sleep(100);

}catch(Exception e){}



muzzleFlash.setNumParticles(0);



}

}



but the muzzleflash doesnt appear at all. I also tried setEnabled but this doesnt work too.

deleting the particle emitter from the rootNode doesnt work either, so does someone have an idea what to do?



if I increase the particle number from 1 zu 5 or so, it does take effect. but when I set it to 0 and then to >0 again, it doesnt appear.

Read the tutorials, you do timers by accumulating tpf in an update() callback like simpleUpdate or a controls update method.

looks like the java time doesnt work in jme3, so I check the current system time in the update loop to attach und detach the muzzleflash, but setLocalTranslation doesnt work for the particle system, it stays at the same spot.



by the way, how can I change the transparency of the particle emitter?