# How can I load the image? (mousePressed, case)

**URL:** https://discourse.processing.org/t/how-can-i-load-the-image-mousepressed-case/29763
**Category:** Coding Questions
**Created:** [April 30, 2021, 11:24pm UTC](https://discourse.processing.org/t/how-can-i-load-the-image-mousepressed-case/29763 "2021-04-30T23:24:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Yujung](https://avatars.discourse-cdn.com/v4/letter/y/a9a28c/32.png) [@Yujung](https://discourse.processing.org/u/Yujung)
#### Post date: [April 30, 2021, 11:24pm UTC](https://discourse.processing.org/t/how-can-i-load-the-image-mousepressed-case/29763/1 "2021-04-30T23:24:51Z")

</div>

After the ‘start’ image appears in case2, I want case3 to appear when I press a certain part. But case3 is not loaded. What could be the problem?

```auto
import processing.video.*;
Movie intro;

int caseNum=1;
PImage start;
PImage press;
PImage cloth1;
boolean btn1=false;

void setup() {
  size (1423, 800);
  intro=new Movie(this, "intro.mp4 ");
  intro.play();
  start=loadImage("start.png");
  press=loadImage("press.png");
  cloth1=loadImage("cloth1.png");
}

void draw() {
  println(caseNum);
  
  switch(caseNum) {
  case 1:
    image(intro, 0, 0, width, height);
    println(intro.time());
    if (intro.time()>=16) {
      caseNum=2;
    }
    break;

  case 2:
    image(start, 0, 0);
    image(press, 500, 620);
       if (mouseX>500 && mouseX<953&&mouseY>620&& mouseY<692) {
      btn1=true;
    } else {
      btn1=false;
   }
    break;

  case 3:
    image(cloth1, 0, 0);
    break;
  }
}

void mousePressed() {
  switch(caseNum) {
    case 2:
    if (btn1==true) {
      caseNum=3;
    }
    break;
  }
}
// Called every time a new frame is available to read
void movieEvent(Movie m) {
  m.read();
}

```

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [April 30, 2021, 11:29pm UTC](https://discourse.processing.org/t/how-can-i-load-the-image-mousepressed-case/29763/2 "2021-04-30T23:29:08Z")

</div>

> [@Yujung](#):
>
> ```auto
> else {
> btn1=false;
> }
> 
> ```

Delete this…?

Chrisir

---

<div class="post-metadata">

### Author: ![Yujung](https://avatars.discourse-cdn.com/v4/letter/y/a9a28c/32.png) [@Yujung](https://discourse.processing.org/u/Yujung)
#### Post date: [May 1, 2021, 9:25am UTC](https://discourse.processing.org/t/how-can-i-load-the-image-mousepressed-case/29763/3 "2021-05-01T09:25:49Z")

</div>

It didn’t work T.T  
But thanks alot!

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [May 1, 2021, 4:37pm UTC](https://discourse.processing.org/t/how-can-i-load-the-image-mousepressed-case/29763/4 "2021-05-01T16:37:11Z")

</div>

You don’t need the variable btn1 at all

Move the `if(mouseX...)` part into the function `mousePressed()` and change caseNum (also referered to as a “state” by the way) there
