# Movie objects all change at the same time

**URL:** https://discourse.processing.org/t/movie-objects-all-change-at-the-same-time/2979
**Category:** Coding Questions
**Created:** [August 25, 2018, 11:09pm UTC](https://discourse.processing.org/t/movie-objects-all-change-at-the-same-time/2979 "2018-08-25T23:09:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![tefa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tefa/32/1181_2.png) [@tefa](https://discourse.processing.org/u/tefa)
#### Post date: [August 25, 2018, 11:09pm UTC](https://discourse.processing.org/t/movie-objects-all-change-at-the-same-time/2979/1 "2018-08-25T23:09:14Z")

</div>

Hello Processors, thank you for your time. I made this object using a Movie object where two videos float up and stay in the top. It works but I also typed a function for each of them to change color when I click on them. It changes the color of all of them at the same time.

```auto
import processing.video.*;
Movie myMovie;
Video v1;
Video v2; 

void setup() {
  size(640, 360);
  myMovie = new Movie(this, "fogata.mp4");
  myMovie.loop();
  v1 = new Video(4096/20, 2160/20);
  v2 = new Video(4096/40, 2160/40);// this is calling the constructor
}

void draw() {
  background(255);
  v1.display();
  v1.ascend();
  v1.top();

  v2.display();
  v2.ascend();
  v2.top();
}

//tint
void mouseClicked() {
  v2.tintit();
  v1.tintit();
}
void movieEvent(Movie m) {
  m.read();
}

class Video {

  //data
  float x;
  float y;
  float sizeW;
  float sizeH;
  float d;

  Video(float tempW, float tempH) {//here is where initialization starts
    x = width/2*random(0, 3);
    y = height;
    sizeW = tempW;
    sizeH= tempH;
  }
  void ascend() {
    y--;
    x = x + random(-2, 2);
  }

  void top() {
    if (y < sizeH/2) {
      y = sizeH/2;
    }
  }

  //functuality: function definitions
  void display() {
    image(myMovie, x, y, sizeW, sizeH);
  }
  
  void tintit() {
    d = dist(mouseX, mouseY, x, y);
    if (d < sizeW && d <sizeW) {
      tint(0, 206, 16);
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![Kevin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kevin/32/2297_2.png) [@Kevin](https://discourse.processing.org/u/Kevin)
#### Post date: [August 25, 2018, 11:11pm UTC](https://discourse.processing.org/t/movie-objects-all-change-at-the-same-time/2979/2 "2018-08-25T23:11:25Z")

</div>

You don’t have any code that check whether the mouse is inside one of the videos. When you click the mouse, anywhere, you tint both videos.

You need to add some code that checks which video you’re in when you click the mouse.

Shameless self-promotion: here is a guide on collision detection in Processing. You’re looking for rectangle-point collision detection.

> **[Processing Collision Detection](https://happycoding.io/tutorials/processing/collision-detection)**
>
> Learn how to trigger an action when objects overlap in Processing!

---

<div class="post-metadata">

### Author: ![tefa](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tefa/32/1181_2.png) [@tefa](https://discourse.processing.org/u/tefa)
#### Post date: [August 25, 2018, 11:13pm UTC](https://discourse.processing.org/t/movie-objects-all-change-at-the-same-time/2979/3 "2018-08-25T23:13:18Z")

</div>

hehe I will look into the collision detection guide.
