# Movieclips as triggers

**URL:** <https://forum.kirupa.com/t/movieclips-as-triggers/184208>\
**Category:** flash\
**Created:** [April 3, 2006, 10:13am UTC](https://forum.kirupa.com/t/movieclips-as-triggers/184208 "2006-04-03T10:13:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sceme](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sceme](https://forum.kirupa.com/u/sceme)\
**Post date:** [April 3, 2006, 10:13am UTC](https://forum.kirupa.com/t/movieclips-as-triggers/184208/1 "2006-04-03T10:13:44Z")

</div>

OK I try my best to explain this. I have this movieclip (instance name “t1”) i use as a trigger when a car (i\_car) hits it. Inside it there is 2 frames. The idea is to get the car going under the bridge when trigged and normally the state is that the car goes above the bridge.

**Frame 1:**  
if (\_root.t2.hitTest(\_root.i\_car)) {  
\_root.i\_bridge.swapDepths(200);  
\_root.t2.\_yscale = 300;  
\_root.track.i\_collision.gotoAndStop(3);  
} else {  
\_root.i\_car.swapDepths(200);  
\_root.t2.\_yscale = 100;  
\_root.track.i\_collision.gotoAndStop(2);  
}  
**Frame 2:**  
gotoAndPlay(1);

I use this trigger at the end of the bridge. (the road going under it). Problem is when ever i put another similiar trigger movieclip, this new trigger doesn’t work. I just can’t find the reason why it wont work.  
This first trigger works fine.

---

<div class="post-metadata">

**Author:** ![sceme](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sceme](https://forum.kirupa.com/u/sceme)\
**Post date:** [April 3, 2006, 10:53am UTC](https://forum.kirupa.com/t/movieclips-as-triggers/184208/2 "2006-04-03T10:53:09Z")

</div>

Ok i solved the problem and here’s the solution if someone is interested.

**I added this script to the first trigger movieclip:**  
onClipEvent (enterFrame) {  
if (this.hitTest(\_root.i\_car)) {  
\_root.i\_bridge.swapDepths(100);  
this.\_yscale = 300;  
\_root.track.i\_collision.gotoAndStop(3);  
} else {  
if (\_root.t2.hitTest(\_root.i\_car)) {  
\_root.i\_bridge.swapDepths(100);  
\_root.t2.\_yscale = 300;  
\_root.track.i\_collision.gotoAndStop(3);  
} else {  
\_root.i\_car.swapDepths(100);  
this.\_yscale = 100;  
\_root.t2.\_yscale = 100;  
\_root.track.i\_collision.gotoAndStop(2);  
}  
}  
}  
----------------------- end -----------------

Now there is another trigger movieclip too (t2) and it works. Both of them:)

---

<div class="post-metadata">

**Author:** ![sceme](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sceme](https://forum.kirupa.com/u/sceme)\
**Post date:** [April 3, 2006, 11:08am UTC](https://forum.kirupa.com/t/movieclips-as-triggers/184208/3 "2006-04-03T11:08:12Z")

</div>

For those who are interested what i needed that thing for:

[http://pixeli.pkky.fi/~meronen/AnokiRacer/beta06.html](http://pixeli.pkky.fi/~meronen/AnokiRacer/beta06.html)

A bridge test. sorry that it is so big on screen but it’s just a test really hehe.

---

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [April 3, 2006, 11:22am UTC](https://forum.kirupa.com/t/movieclips-as-triggers/184208/4 "2006-04-03T11:22:10Z")

</div>

why dont you make the bridge a diferent movieClip, and apply that ac when the car goes down the bridge. if i was youm this i will do 🙂 i hope i gave you a ideea.

---

<div class="post-metadata">

**Author:** ![sceme](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@sceme](https://forum.kirupa.com/u/sceme)\
**Post date:** [April 3, 2006, 11:30am UTC](https://forum.kirupa.com/t/movieclips-as-triggers/184208/5 "2006-04-03T11:30:57Z")

</div>

I did. (i\_bridge) is the bridge’s movieclip instance name : ) And as i said it works now.

---

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [April 3, 2006, 11:36am UTC](https://forum.kirupa.com/t/movieclips-as-triggers/184208/6 "2006-04-03T11:36:39Z")

</div>

i tested know, and when i go under the bridge the car is out.

---

<div class="post-metadata">

**Author:** ![btibia](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/btibia/32/1625_2.png) [@btibia](https://forum.kirupa.com/u/btibia)\
**Post date:** [April 3, 2006, 11:37am UTC](https://forum.kirupa.com/t/movieclips-as-triggers/184208/7 "2006-04-03T11:37:40Z")

</div>

ok, know it is working…
