# Attach movie based on another movies coordinates

**URL:** <https://forum.kirupa.com/t/attach-movie-based-on-another-movies-coordinates/183641>\
**Category:** Uncategorized\
**Created:** [March 28, 2006, 11:56pm UTC](https://forum.kirupa.com/t/attach-movie-based-on-another-movies-coordinates/183641 "2006-03-28T23:56:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcurrid](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pcurrid](https://forum.kirupa.com/u/pcurrid)\
**Post date:** [March 28, 2006, 11:56pm UTC](https://forum.kirupa.com/t/attach-movie-based-on-another-movies-coordinates/183641/1 "2006-03-28T23:56:06Z")

</div>

hi guys,  
I’m trying to create some flash that will attach a movie(collision\_mc) only when another movies (camerView) x and z coordinates are met.  
I am trying to do this within a for loop, and it is embedded within a game I’ve gotten from the 3D in Flash tutorials on this site.

Should I set this up within the same for loop as the rest of the movies that populate the scene, or should I set up a new for loop (as I have done)??  
I am now trying to use onEnterFrame as I couldnt get it working properly without  
I can not get it working for some reason.  
Please see line 119-134 for relevant code.  
you will have to comment out those lines to see the game before I tried to mess with this.  
my fla file was too big so Ive attached the swf if thats any help?!

any suggestions would be really appreciated!

---

<div class="post-metadata">

**Author:** ![unchew](https://avatars.discourse-cdn.com/v4/letter/u/7ba0ec/32.png) [@unchew](https://forum.kirupa.com/u/unchew)\
**Post date:** [March 29, 2006, 2:24am UTC](https://forum.kirupa.com/t/attach-movie-based-on-another-movies-coordinates/183641/2 "2006-03-29T02:24:02Z")

</div>

1.- That swf does nothing 😛  
2.- I didn’t understand a word  
3.- from what I understood from the topic title, you want to load a movie in the coordinates given by another movie. Well, using on enterFrame you can tell the coordinate movie to record its \_x and \_y in the \_root movie \_root.movieX=\_x, \_root.movieY=\_y.

Then when calling the attatch, use those variables.

If that is not what you meant… Then I’m sorry not to be able to help you 😃

---

<div class="post-metadata">

**Author:** ![pcurrid](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pcurrid](https://forum.kirupa.com/u/pcurrid)\
**Post date:** [March 29, 2006, 8:50am UTC](https://forum.kirupa.com/t/attach-movie-based-on-another-movies-coordinates/183641/3 "2006-03-29T08:50:54Z")

</div>

sorry, I should have commented out the code that was affecting the rest of the game before sending :ponder:.  
not quite what I meant. I have an if statement that I have been tinkering with. I can sort of get it to work without using the onEnterFrame, but not quite, so I tried this way

[//cameraView.onEnterFrame](https://cameraView.onEnterFrame)()  
//for (i=0;i\<10;i++){

```
//if (i&lt;1 and cameraView.x &gt;=-450 and cameraView.x &lt;=450 and camerView.z &lt;=3000 and cameraView.z &gt;=4000) {
        //collision = theScene.attachMovie("collision_mc", "collision_mc"+i, i);
        //collision.x = 450;
        //collision.z = 3500;
        //collision.y = 0;
        //}

```

//else  
[//theScene.removeMovieClip](https://theScene.removeMovieClip)(“collision\_mc”);

//collision\_mc.display = displayFigure;  
[//objectsInScene.push](https://objectsInScene.push)(collision\_mc);  
//}

---

<div class="post-metadata">

**Author:** ![optixburn](https://avatars.discourse-cdn.com/v4/letter/o/82dd89/32.png) [@optixburn](https://forum.kirupa.com/u/optixburn)\
**Post date:** [March 29, 2006, 4:39pm UTC](https://forum.kirupa.com/t/attach-movie-based-on-another-movies-coordinates/183641/4 "2006-03-29T16:39:43Z")

</div>

> [@pcurrid](#):
>
> sorry, I should have commented out the code that was affecting the rest of the game before sending :ponder:.  
> not quite what I meant. I have an if statement that I have been tinkering with. I can sort of get it to work without using the onEnterFrame, but not quite, so I tried this way
> 
> [//cameraView.onEnterFrame](https://cameraView.onEnterFrame)()  
> //for (i=0;i\<10;i++){
> 
> ```
> //if (i&lt;1 and cameraView.x &gt;=-450 and cameraView.x &lt;=450 and camerView.z &lt;=3000 and cameraView.z &gt;=4000) {
> //collision = theScene.attachMovie("collision_mc", "collision_mc"+i, i);
> //collision.x = 450;
> //collision.z = 3500;
> //collision.y = 0;
> //}
> 
> ```
> 
> //else  
> [//theScene.removeMovieClip](https://theScene.removeMovieClip)(“collision\_mc”);
> 
> //collision\_mc.display = displayFigure;  
> [//objectsInScene.push](https://objectsInScene.push)(collision\_mc);  
> //}

we need a your fla source to help you out anymore … we can’t get it from your swf file …

the above code should have some more braces in them and you need to set the cameraView.onEnterFrame to be a function … right now you have it point to nothing …

the next question is why do you have a for loop of 10?

it looks like you have the cameraView set an empty onEnterFrame and then have the game check for collision 10 times

[AS]  
cameraView.onEnterFrame = function(){  
for (i=0;i\<10;i++){  
if (i\<1 and cameraView.x \>=-450 and cameraView.x \<=450 and camerView.z \<=3000 and cameraView.z \>=4000) {  
collision = theScene.attachMovie(“collision\_mc”, “collision\_mc”+i, i);  
collision.x = 450;  
collision.z = 3500;  
collision.y = 0;  
}else {  
theScene.removeMovieClip(“collision\_mc”);  
}  
collision\_mc.display = displayFigure;  
objectsInScene.push(collision\_mc);  
}  
}  
[/AS]

if we could get your fla or at least your code up on the forum we could help you better

hope this helps a little

-Justin

---

<div class="post-metadata">

**Author:** ![pcurrid](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@pcurrid](https://forum.kirupa.com/u/pcurrid)\
**Post date:** [March 29, 2006, 5:58pm UTC](https://forum.kirupa.com/t/attach-movie-based-on-another-movies-coordinates/183641/5 "2006-03-29T17:58:25Z")

</div>

hi,  
I tried to upload the fla but it was too large (88kb and the limit is 75),  
is there any other way for me to upload the file?
