# MX Bug? Problem?

**URL:** <https://forum.kirupa.com/t/mx-bug-problem/7637>\
**Category:** flash\
**Created:** [November 4, 2002, 11:39pm UTC](https://forum.kirupa.com/t/mx-bug-problem/7637 "2002-11-04T23:39:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewreporting](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@drewreporting](https://forum.kirupa.com/u/drewreporting)\
**Post date:** [November 4, 2002, 11:39pm UTC](https://forum.kirupa.com/t/mx-bug-problem/7637/1 "2002-11-04T23:39:14Z")

</div>

In Flash MX whenever I seem to program any random movement it never shows up when I test it or whenever I export it. The movie clips appear but they are motionless. If anyone knows what this is or how to solve it please reply. Thanx a lot

```
 -Drew=)
```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 5, 2002, 4:14am UTC](https://forum.kirupa.com/t/mx-bug-problem/7637/2 "2002-11-05T04:14:27Z")

</div>

What is the code you are using to program the movement?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 5, 2002, 2:29pm UTC](https://forum.kirupa.com/t/mx-bug-problem/7637/3 "2002-11-05T14:29:52Z")

</div>

code would help… 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 5, 2002, 11:12pm UTC](https://forum.kirupa.com/t/mx-bug-problem/7637/4 "2002-11-05T23:12:16Z")

</div>

O.K. Here’s the code. I pasted this in the first keyframe of my action layer. This is from Kirupa’s Tutorial on random motion.

function getdistance (x, y, x1, y1) {  
var run, rise;  
run = x1-x;  
rise = y1-y;  
return (hyp(run, rise));  
}  
function hyp (a, b) {  
return (Math.sqrt(a_a+b_b));  
}  
MovieClip.prototype.reset = function () {  
var dist, norm, movie\_height, movie\_width;

movie\_height = 150;  
movie\_width = 300;

speed = Math.random()_4+2;  
targx = Math.random()_(movie\_width-\_width);  
targy = Math.random()\*(movie\_height-\_height);  
dist = \_root.getdistance(\_x, \_y, targx, targy);

norm = speed/dist;  
diffx = (targx-\_x)\*norm;  
diffy = (targy-\_y)\*norm;  
};

MovieClip.prototype.move = function () {  
var cycle;

if (\_root.getdistance(\_x, \_y, targx, targy)\>speed) {x += diffx;y += diffy;  
} else {x = targx;  
y = targy;  
if (!this.t) {  
t = getTimer();  
}if (getTimer()-t\>cycle) {reset();  
t = 0;  
}  
}  
\_x = x;  
\_y = y;  
}

This was pasted in the movie clips I wanted to move:

onClipEvent (enterFrame) {  
move();  
}

I’m pretty sure something is not wrong with the code because I have copied and pasted it from tutorials after I found out some other codes didn’t work.
