# Why won't it work

**URL:** <https://forum.kirupa.com/t/why-wont-it-work/15395>\
**Category:** Uncategorized\
**Created:** [March 13, 2003, 6:49pm UTC](https://forum.kirupa.com/t/why-wont-it-work/15395 "2003-03-13T18:49:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Law](https://avatars.discourse-cdn.com/v4/letter/l/4af34b/32.png) [@Law](https://forum.kirupa.com/u/Law)\
**Post date:** [March 13, 2003, 6:49pm UTC](https://forum.kirupa.com/t/why-wont-it-work/15395/1 "2003-03-13T18:49:43Z")

</div>

before i ask my question i just want to say sorry for posting this question in the actionscript foum and this forum but it had been a little while and nobody had posted in there let alone replied to my thread so i went in and found that it was empty so i decided to post the question here. sorry again.

why won’t it work  
i had this code in a movie clip food1

PHP:--------------------------------------------------------------------------------

```php
onClipEvent (enterFrame) {
    if (_root["food"+y], hitTest(_root.part1)) {
        snakelength++;
        x++;
        y++;
        duplicateMovieClip("food"+x, "food"+y, y);
        _root["food"+y]._x = (random(55))*10
        _root["food"+y]._y = (random(40))*10
    }
}

```

* * *

but of course when i duplicated the movieclip it didn’t keep the code because i changed the instace name but i wanted to be able to remove food1, so i put the code in a blank movie clip. I thought i had written the code so that it didn’t matter what movieclip it was in, but it worked in food1 but not in the blank movieclip. someone please help me. 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:** [March 13, 2003, 7:22pm UTC](https://forum.kirupa.com/t/why-wont-it-work/15395/2 "2003-03-13T19:22:58Z")

</div>

try this:

Put this on food1 and move it outside of the stage. You are only using this MC to hold the code. Nothing else.

```php

onClipEvent(enterFrame){
     if(this._name != "food1"){
          nFlag = this.hitTest(_root.part1);
          snakelength++;
          ii++;
          _root.food1.duplicateMovieClip("food"+ii, ii);
          _root["food"+ii]._x = (random(55))*10
          _root["food"+ii]._y = (random(40))*10
     }
}

```

Try that… it **might** work. I can’t test it because I don’t haev FLash on me…

I will delete the post in the other forum…

---

<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:** [March 13, 2003, 8:05pm UTC](https://forum.kirupa.com/t/why-wont-it-work/15395/3 "2003-03-13T20:05:24Z")

</div>

thanks for the reply jubba, but I’m using a different appoach now.
