# Random Motion

**URL:** <https://forum.kirupa.com/t/random-motion/2583>\
**Category:** flash\
**Created:** [November 11, 2001, 7:03pm UTC](https://forum.kirupa.com/t/random-motion/2583 "2001-11-11T19:03:19Z")\
**Posts on this page:** 17\
**Page:** 2

<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:** [May 5, 2002, 2:51pm UTC](https://forum.kirupa.com/t/random-motion/2583/21 "2002-05-05T14:51:58Z")

</div>

There’s a problem of scope of variables when you declare prototypes and functions. I tried to explain it there :\r[www.kirupa.com/developer/…pring2.asp](http://www.kirupa.com/developer/actionscript/spring2.asp)\rBut I didn’t try to make it work… Tell us if you have troubles.\r\rpom 0]

---

<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:** [May 5, 2002, 7:50pm UTC](https://forum.kirupa.com/t/random-motion/2583/22 "2002-05-05T19:50:52Z")

</div>

Hey Ilyas,  
Thanx for the reply.  
I checked your post. It cleared atleast one particular confusion… i had always wondered why it was necessary to write “this.\_x” when u could get the same result with a plain “\_x”. but there is another file i am stuck with right now. Have u checked the new Flash Math Creativity book?.. pretty awesome stuff on it. So here is another question. In my MX actionscript reference, it says that the ‘prototype’ command was only adopted in the flash 6 player… then how come all the code on this book , which apparently has been written in flash 5, has the prototype keyword in it?..  
secondly, if u check the code for the files on the book…  
[www.friendsofed.com/fmc/downloads](http://www.friendsofed.com/fmc/downloads)  
i was trying to make the first file by jamie mcdonald, titled towardUs to work in flash MX… this one also has the prototype declaration in it, and it still doesnt work…  
can u tell me what the problem is?  
Thanx Again.

---

<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:** [May 6, 2002, 10:12pm UTC](https://forum.kirupa.com/t/random-motion/2583/23 "2002-05-06T22:12:15Z")

</div>

I’ll check that. But they said on the forum that it was a problem of \*\* this.\*\*…

pom 0]

Prototypes exist in F5

---

<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:** [May 7, 2002, 8:29pm UTC](https://forum.kirupa.com/t/random-motion/2583/24 "2002-05-07T20:29:33Z")

</div>

i’ve changed the code to work in mx.

like ily was saying, mostly just putting “this” in front of everything.

---

<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:** [May 26, 2002, 12:44pm UTC](https://forum.kirupa.com/t/random-motion/2583/25 "2002-05-26T12:44:50Z")

</div>

Could you please post the code as you modified it for MX? Thanks.

---

<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:** [May 26, 2002, 1:02pm UTC](https://forum.kirupa.com/t/random-motion/2583/26 "2002-05-26T13:02:04Z")

</div>

he did. Its the 4th post in this thread. Go back to the first page and go down to the 4th post. Its the one that says that it was edited 5-7-02

---

<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:** [May 26, 2002, 5:27pm UTC](https://forum.kirupa.com/t/random-motion/2583/27 "2002-05-26T17:27:59Z")

</div>

Thanks.

---

<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:** [May 27, 2002, 10:55am UTC](https://forum.kirupa.com/t/random-motion/2583/28 "2002-05-27T10:55:30Z")

</div>

i cant get this to work, i am still new to more advanced aspects of actionscripting i make my object to move randoly convert to movie clip, insert button but i cant find anywhere to put the actionscript for the goto command, please 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:** [May 27, 2002, 1:47pm UTC](https://forum.kirupa.com/t/random-motion/2583/29 "2002-05-27T13:47:53Z")

</div>

on the button.

---

<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:** [May 27, 2002, 6:08pm UTC](https://forum.kirupa.com/t/random-motion/2583/30 "2002-05-27T18:08:50Z")

</div>

no still not working. right here is what im doing. following the tutorial adding the actionscript, drawing a circle convert that to movieclip then converting that to button, so now i have a movieclip and button in the library. trying to add script to the button when it is selected is impossable as there is no actions in the drop down menu. ( if that make sence) when and where do i add my on mouse event goto stuff. what the hell am i doing wrong? it is probably so mind mumbingly simple to you lot. but it is pissing me off.

---

<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:** [May 27, 2002, 6:12pm UTC](https://forum.kirupa.com/t/random-motion/2583/31 "2002-05-27T18:12:03Z")

</div>

That’s a tough tutorial, maybe the toughest (???) on this site… Did you try and look at the source ? aybe you can compare.

pom 0]

---

<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:** [May 27, 2002, 6:25pm UTC](https://forum.kirupa.com/t/random-motion/2583/32 "2002-05-27T18:25:35Z")

</div>

if i’m understanding correctly, you’ll want to have a button within a movieclip, not a movieclip within a button.

is that how you have it now?

then the button actions can go on the button in the movieclip, and onClipEvent actions can go on the movies, and everything else can go in frame 1 of \_root.

if you’re using mx, you can do something like this on the movies:

```auto
 
onClipEvent(load){
&nbsp &nbsp &nbsp &nbsp this.onRelease = function(){ trace("released!"); };
}

```

and do away with your buttons altogether.

---

<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:** [May 27, 2002, 9:22pm UTC](https://forum.kirupa.com/t/random-motion/2583/33 "2002-05-27T21:22:38Z")

</div>

what i have been told is that i need a button inside a movieclip. make the movie clip then convert that to button ( is that right?). then add script the button. i am using flash 5 for this but i also have mx.

i need a tutorial cos i have had no real time to sit down and learn actionscrript being at uni and all. anyone know any books that are essential reading i already have foundation flash (FOED) which i havent read yet.

---

<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:** [May 27, 2002, 10:01pm UTC](https://forum.kirupa.com/t/random-motion/2583/34 "2002-05-27T22:01:08Z")

</div>

almost right, make the button, and convert it to a movieclip.

---

<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:** [May 27, 2002, 10:27pm UTC](https://forum.kirupa.com/t/random-motion/2583/35 "2002-05-27T22:27:34Z")

</div>

thanks everyone, you’ve been a great 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:** [May 31, 2002, 9:53pm UTC](https://forum.kirupa.com/t/random-motion/2583/36 "2002-05-31T21:53:12Z")

</div>

I’ve got several different objects that scroll downwards but they all group together on the same y level and tend to clump together on the x. Is there a way to spread them out completely, in random order (I’ve got 7 different, looping objects)

Here’s what I’ve been using:  
onClipEvent (load) {  
function reset () {  
this.\_x = random(300);  
this.\_y = random-(200);  
loopSpeed = 6;  
}  
reset();  
}  
onClipEvent (enterFrame) {  
if (\_root.dragon.scrollStart){  
this.\_y+=loopSpeed;  
} else {  
this.\_y+=loopSpeed;  
}  
if (this.\_y\>575) {  
reset();  
}  
}

Any help would be appreciated!  
Tx  
§

---

<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:** [June 1, 2002, 3:39am UTC](https://forum.kirupa.com/t/random-motion/2583/37 "2002-06-01T03:39:55Z")

</div>

Never mind, I used a variant of the answer in the "Suprabeener: A quick Q: " post. Thank you! 🙂  
§

[Previous page](https://forum.kirupa.com/t/random-motion/2583.md?page=1)
