# Shoot'em up game isn't working

**URL:** <https://forum.kirupa.com/t/shootem-up-game-isnt-working/183528>\
**Category:** flash\
**Created:** [March 27, 2006, 11:41pm UTC](https://forum.kirupa.com/t/shootem-up-game-isnt-working/183528 "2006-03-27T23:41:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![11113](https://avatars.discourse-cdn.com/v4/letter/1/e9c0ed/32.png) [@11113](https://forum.kirupa.com/u/11113)\
**Post date:** [March 27, 2006, 11:41pm UTC](https://forum.kirupa.com/t/shootem-up-game-isnt-working/183528/1 "2006-03-27T23:41:29Z")

</div>

been trying to get this thing to generate a movie clip randomly on the \_x at any random position on the \_y 250. Here’s the source file i got from a site and erased all the script so i could start from scratch on my own, it doesn’t seem to be working.

[http://www.feverupload.com/download.php?file=2edfb4282160e7241ef1eb424513dc40](http://www.feverupload.com/download.php?file=2edfb4282160e7241ef1eb424513dc40)

```
 ActionScript Code:
 [FONT=Courier New][LEFT]&lt;b&gt;[COLOR=#808080]*//box.startDrag(true, 0, 350, 550, 100 );*[/COLOR]

```

[COLOR=#0000ff]start[/COLOR].[COLOR=#0000ff]onPress[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR]:[COLOR=#0000ff]Void[/COLOR][COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“enemy”[/COLOR], [COLOR=#ff0000]“mcEnemy”[/COLOR], [COLOR=#000080]1[/COLOR][COLOR=#000000])[/COLOR];  
mcEnemy.[COLOR=#0000ff]\_xscale[/COLOR] = [COLOR=#000080]25[/COLOR];  
mcEnemy.[COLOR=#0000ff]\_yscale[/COLOR] = [COLOR=#000080]25[/COLOR];  
mcEnemy.[COLOR=#0000ff]\_y[/COLOR] = [COLOR=#000080]225[/COLOR];  
mcEnemy.[COLOR=#0000ff]\_x[/COLOR] = [COLOR=#0000ff]random[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#808080]_/var begin:Number = setInterval(animate, 100);/_[/COLOR]  
[COLOR=#000000]}[/COLOR]  
box.[COLOR=#0000ff]onMouseDown[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR]:[COLOR=#0000ff]Void[/COLOR][COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]play[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR];  
[COLOR=#000000] **function** [/COLOR] animateCOLOR=#000000[/COLOR]:[COLOR=#0000ff]Void[/COLOR][COLOR=#000000]{[/COLOR]  
[COLOR=#808080]_[//this.attachMovie](https://this.attachMovie)(“enemy”, “mcEnemy”, 1);_[/COLOR]  
mcEnemy.[COLOR=#0000ff]\_y[/COLOR] = [COLOR=#000080]225[/COLOR];  
mcEnemy.[COLOR=#0000ff]\_x[/COLOR] = [COLOR=#0000ff]random[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]mcEnemy.[COLOR=#0000ff]\_x[/COLOR] \< [COLOR=#000080]300[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]  
mcEnemy.[COLOR=#0000ff]\_x[/COLOR]++;  
mcEnemy.\_y–;  
mcEnemy.[COLOR=#0000ff]\_xscale[/COLOR]++;  
mcEnemy.[COLOR=#0000ff]\_yscale[/COLOR]++  
[COLOR=#000000]}[/COLOR]  
[COLOR=#0000ff]else[/COLOR][COLOR=#000000]{[/COLOR]  
mcEnemy.\_x–;  
mcEnemy.\_y–;  
mcEnemy.[COLOR=#0000ff]\_xscale[/COLOR]++;  
mcEnemy.[COLOR=#0000ff]\_yscale[/COLOR]++;  
[COLOR=#000000]}[/COLOR]  
[COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR]mcEnemy.[COLOR=#0000ff]\_y[/COLOR] == [COLOR=#000080]300[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]clearInterval[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000] **function** [/COLOR] thisWorksCOLOR=#000000[/COLOR]:[COLOR=#0000ff]Void[/COLOR][COLOR=#000000]{[/COLOR]  
[COLOR=#0000ff]Mouse[/COLOR].[COLOR=#0000ff]hide[/COLOR]COLOR=#000000[/COLOR];  
crosshair.[COLOR=#0000ff]\_x[/COLOR] = [COLOR=#0000ff]\_root[/COLOR].[COLOR=#0000ff]\_xmouse[/COLOR];  
crosshair.[COLOR=#0000ff]\_y[/COLOR] = [COLOR=#0000ff]\_root[/COLOR].[COLOR=#0000ff]\_ymouse[/COLOR];  
box.[COLOR=#0000ff]\_x[/COLOR] = [COLOR=#0000ff]\_root[/COLOR].[COLOR=#0000ff]\_xmouse[/COLOR];  
box.[COLOR=#0000ff]\_y[/COLOR] = [COLOR=#0000ff]\_root[/COLOR].[COLOR=#0000ff]\_ymouse[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000] **var** [/COLOR] workNOW:[COLOR=#0000ff]Number[/COLOR] = [COLOR=#0000ff]setInterval[/COLOR]COLOR=#000000[/COLOR];  
\</b\>  
[/LEFT]  
[/FONT]

---

<div class="post-metadata">

**Author:** ![11113](https://avatars.discourse-cdn.com/v4/letter/1/e9c0ed/32.png) [@11113](https://forum.kirupa.com/u/11113)\
**Post date:** [March 27, 2006, 11:49pm UTC](https://forum.kirupa.com/t/shootem-up-game-isnt-working/183528/2 "2006-03-27T23:49:18Z")

</div>

by the way, i want the movie clip to move to 300 x , 300 y that’s when it is supposed to hit the person and then disappear, just saw that the y-- is supposed to be y++ let me go test that out.

---

<div class="post-metadata">

**Author:** ![11113](https://avatars.discourse-cdn.com/v4/letter/1/e9c0ed/32.png) [@11113](https://forum.kirupa.com/u/11113)\
**Post date:** [March 27, 2006, 11:50pm UTC](https://forum.kirupa.com/t/shootem-up-game-isnt-working/183528/3 "2006-03-27T23:50:14Z")

</div>

here are the changes

```auto

//box.startDrag(true, 0, 350, 550, 100 );
start.onPress = function():Void{
    this.attachMovie("enemy", "mcEnemy", 1);
    mcEnemy._xscale = 25;
    mcEnemy._yscale = 25;
    mcEnemy._y = 225;
    mcEnemy._x = random(550);
    /*var begin:Number = setInterval(animate, 100);*/
}
box.onMouseDown = function():Void{
    this.play();
};
function animate():Void{
    //this.attachMovie("enemy", "mcEnemy", 1);
    mcEnemy._y = 225;
    mcEnemy._x = random(550);
    if(mcEnemy._y == 300 && mcEnemy._x == 300){
        clearInterval(begin);
    }
    if(mcEnemy._y < 300){
        mcEnemy._y++;
    }
    else{
        mcEnemy._y--;
    }
    if(mcEnemy._x < 300){
            mcEnemy._x++;
            mcEnemy._xscale++;
            mcEnemy._yscale++
    }
    else{
            mcEnemy._x--;
            mcEnemy._xscale++;
            mcEnemy._yscale++;
    }

}
function thisWorks():Void{
    Mouse.hide();
    crosshair._x = _root._xmouse;
    crosshair._y = _root._ymouse;
    box._x = _root._xmouse;
    box._y = _root._ymouse;
}
var workNOW:Number = setInterval(thisWorks,10);

```

---

<div class="post-metadata">

**Author:** ![11113](https://avatars.discourse-cdn.com/v4/letter/1/e9c0ed/32.png) [@11113](https://forum.kirupa.com/u/11113)\
**Post date:** [March 28, 2006, 12:22am UTC](https://forum.kirupa.com/t/shootem-up-game-isnt-working/183528/4 "2006-03-28T00:22:28Z")

</div>

ok i see the problem now, i’ve been attaching the movieclip to the button movieclip called “start”, i said “this.attachMovie” when i shoudl have said “\_root.attachMovie” to tell the movieclip to go on the main timeline.

testing… it works! now just need to add a bit more scripting to finish it off
