# A specific spot with unspecific coordinates

**URL:** <https://forum.kirupa.com/t/a-specific-spot-with-unspecific-coordinates/117037>\
**Category:** Uncategorized\
**Created:** [July 23, 2004, 4:41pm UTC](https://forum.kirupa.com/t/a-specific-spot-with-unspecific-coordinates/117037 "2004-07-23T16:41:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![N3K0](https://avatars.discourse-cdn.com/v4/letter/n/67e7ee/32.png) [@N3K0](https://forum.kirupa.com/u/N3K0)\
**Post date:** [July 23, 2004, 4:41pm UTC](https://forum.kirupa.com/t/a-specific-spot-with-unspecific-coordinates/117037/1 "2004-07-23T16:41:12Z")

</div>

[font=Arial]I modified the falling snow to move upwards to make bubbles, but now I want them to come from a specific spot from movie clip which is moving constantly and roating. They also have to stay within the bounds of the water.  
I tried placing it on the spot I want on the movie clip, and alter the code like so:

```auto

 onClipEvent (load) {
 	//variables that will modify the rising bubbles
 	i = 1+Math.random()*2;
 	k = -Math.PI+Math.random()*Math.PI;
 	
 	//giving each bubble unique characteristics
 	this._xscale = this._yscale=50+Math.random()*100;
 	this._alpha = 75+Math.random()*100;
 }
 onClipEvent (enterFrame) {
 	//putting it all together
 	rad += (k/180)*Math.PI;
 	this._x -= Math.cos(rad);
 	this._y -= i;
 	if (this._y<=_root.waterLevel) {
 	//go to the clip which duplicates the bubbles
 		this._y = _parent._y;
 		this._x = _parent._x;
 	}
 	if ((this._x>=555) || (this._x<=45)) {
 		this._y = _parent._y;
 		this._x = _parent._x;
 	}
 }
 

```

But with that, the bubble clip ends up 100 pixels behind where i placed it, and theres no movement or duplication. :h:  
[/font]

---

<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:** [July 23, 2004, 5:29pm UTC](https://forum.kirupa.com/t/a-specific-spot-with-unspecific-coordinates/117037/2 "2004-07-23T17:29:18Z")

</div>

I hate when I make a forum post and figure part of it out on my own…

I broke the first rule: the movie clip has to be at 0,0 for it work properly

To properly place the bubbles however, I first find the difference in coordinates between the target and what im placing, then instead of

```auto
 this._y = _parent._y; 

```

I change them to

```auto
 this._y = _root.target._y + dy 

```

where dy is target.\_y - location.\_y;

But that’s the easy part. Here is the tricky part:  
That doesn’t factor in the rotation! (dun dun dun)

The target is rotating at:

```auto
Math.sin(timenow+.9)*2;

```

where timenow is the milliseconds converted into seconds.  
So, how does the rotation effect dx and dy? (My trig is rusty 😊 )  
----EDIT-----  
Ok! I’ll answer my own question again before somsone can point me to [this tuitorial](http://www.kirupaforum.com/forums/showthread.php?t=36907&page=2&pp=15&highlight=trig)

Using my dx and dy, I need to find the hypotenuse of an imaginary right triangle, the hypotenuse is the line beginning from the target.\_x and \_y and stretching to my location.\_x and \_y. Then… I rotate it by the same rotation and convert back to dx and dy, and I do all of this using mathmatics. None of which I can do. I’ll go study now.
