# enableFlash() with KetaiCamera

**URL:** <https://discourse.processing.org/t/enableflash-with-ketaicamera/9017>\
**Category:** Processing for Android\
**Created:** [March 6, 2019, 3:26pm UTC](https://discourse.processing.org/t/enableflash-with-ketaicamera/9017 "2019-03-06T15:26:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![garrettlynch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/garrettlynch/32/19853_2.png) [@garrettlynch](https://discourse.processing.org/u/garrettlynch)\
**Post date:** [March 6, 2019, 3:26pm UTC](https://discourse.processing.org/t/enableflash-with-ketaicamera/9017/1 "2019-03-06T15:26:49Z")

</div>

Anyone here worked with KetaiCamera? I’m trying to turn the flash on and off with mousePressed() and mouseReleased() but it only works the first time unless I dispose of the camera each time I turn the flash off (see code below). Anyone know why?

```auto
import ketai.camera.*;

KetaiCamera cam;
boolean flashactive = false; 

void setup()
{
  cam = new KetaiCamera(this, 320, 240, 24);
  cam.start();
  background(255, 0, 0);
}

void draw()
{

}

void onCameraPreviewEvent()
{
  cam.read();
}

void mousePressed()
{
  if (flashactive == false)
  {
    cam.start();
    cam.enableFlash();
    
    fill(0, 255, 0);
    rect(0, 0, width, height);
    flashactive = true;
  } 
}

void mouseReleased()
{
  if (flashactive == true)
  {
    cam.disableFlash();
    cam.dispose(); //flash won't turn on again if I don't dispose of camera
    
    fill(255, 0, 0);
    rect(0, 0, width, height);
    flashactive = false;
  }
}

```

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [March 8, 2019, 10:32am UTC](https://discourse.processing.org/t/enableflash-with-ketaicamera/9017/2 "2019-03-08T10:32:59Z")

</div>

@garrettlynch ===

i tried your code commenting/uncommenting dispose() : it works (more quickly when i dont dispose(), which is normal); so i dont think that it is a problem with Ketai; can you try the code with another device?
