# Q on how to do cloud movement

**URL:** <https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904>\
**Category:** Uncategorized\
**Created:** [January 9, 2003, 4:02am UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904 "2003-01-09T04:02:29Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![ienjoypie](https://avatars.discourse-cdn.com/v4/letter/i/f9ae1b/32.png) [@ienjoypie](https://forum.kirupa.com/u/ienjoypie)\
**Post date:** [January 9, 2003, 4:02am UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/1 "2003-01-09T04:02:29Z")

</div>

pretty simple question for most of you prolly… i’m still trying to wade myself through the Ocean of Actionscript ;p.

My basic layout is i got ground… and above the ground… i got a sky (pretty complex eh)

I got a few clouds up in the sky that i just want to move to the right, and keep moving across the screen non-stop, i looked at most the tutorials with movement across the screen, but they coincided with mouse movement…and i dun want them to be affected by the mouse.

If someone could just point me in the right direction it’s be much appreciated =D

---

<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:** [January 9, 2003, 6:48am UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/2 "2003-01-09T06:48:45Z")

</div>

let’s make it interesting … lol

place this script in your maintimeline:

```auto
MovieClip.prototype.moveMe = function (begin, end, speed) {
	if (this._x <= end) {
		this._x += speed
	} else {
		this._x = begin
	}
}

```

now place this script in every cloud:

```auto
onClipEvent (load) {
	var begin = (0 - (this._width / 2))
	var end = (Stage.width + (this._width / 2))
	var speed = Math.round (((Math.random() * 4) + 1))
}
onClipEvent (enterFrame) {
	this.moveMe (begin, end, speed)
}

```

the script will move the clouds at a random speed [1 - 4] to the right  
when the mc is not visible anymore [at the right] … it will return to the other side [the left] and move again to the right

[size=1]\*\*PS: \*\*my scripting skills are not that good … so maybe someone can clear up the code for you[/size]

---

<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:** [January 9, 2003, 2:23pm UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/3 "2003-01-09T14:23:07Z")

</div>

Hey man, I just tryed the code… It works amazing!

great work 🙂

p.s. i know this wasnt my question but it’s still good to know 😉

---

<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:** [January 9, 2003, 5:17pm UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/4 "2003-01-09T17:17:38Z")

</div>

Hey can you post a URL of what he is trying to do??? SO i can see what he is doing and to see what it looks like???

---

<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:** [January 9, 2003, 6:34pm UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/5 "2003-01-09T18:34:02Z")

</div>

> \*Originally posted by SureShot \*  
> \*\*Hey man, I just tryed the code… It works amazing!

great work 🙂

p.s. i know this wasnt my question but it’s still good to know 😉 \*\*

thanx!! :beam:

but surely there’s a better or easiest way to do that … i’ll try later  
i’m a little busy right now :-\

---

<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:** [January 9, 2003, 7:11pm UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/6 "2003-01-09T19:11:47Z")

</div>

nice footer sureshot!

---

<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:** [January 9, 2003, 10:21pm UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/7 "2003-01-09T22:21:27Z")

</div>

well…here’s an .fla of what im doin wit the whole cloud thing…

i’m just experimenting around wit stuff, it’s just for our school site… it’s kinna cartooney but _shrugs_ oh well.

edit: oops… almost forgot, thanx a lot for the script Kax =D

---

<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:** [January 9, 2003, 11:20pm UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/8 "2003-01-09T23:20:51Z")

</div>

hey that’s pretty cool =)

glad you like the script 😉

---

<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:** [January 10, 2003, 1:03am UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/9 "2003-01-10T01:03:42Z")

</div>

Thanks a lot 🙂 I am not the best in flash but I am learning!:asian:

---

<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:** [January 10, 2003, 1:39am UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/10 "2003-01-10T01:39:22Z")

</div>

how can you make the clouds move the opposite direction?

---

<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:** [January 10, 2003, 1:59am UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/11 "2003-01-10T01:59:49Z")

</div>

change the start position to the other end of the stage and subtract pixels instead of adding them

Peace

---

<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:** [January 10, 2003, 2:14am UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/12 "2003-01-10T02:14:41Z")

</div>

position the other end is not working…please help?

MovieClip.prototype.moveMe = function (begin, end, speed) {  
if (this.\_x \<= end) {  
this.\_x += speed  
} else {  
this.\_x = begin  
}  
}--------------------------------------------------------------------------------

now place this script in every cloud:

code:--------------------------------------------------------------------------------onClipEvent (load) {  
var begin = (0 - (this.\_width / 2))  
var end = (Stage.width + (this.\_width / 2))  
var speed = Math.round (((Math.random() \* 4) + 1))  
}  
onClipEvent (enterFrame) {  
this.moveMe (begin, end, speed)  
}

Thanx.

---

<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:** [January 11, 2003, 1:03am UTC](https://forum.kirupa.com/t/q-on-how-to-do-cloud-movement/10904/13 "2003-01-11T01:03:46Z")

</div>

any help on this??? Please…
