# Flash as2 Using timer to call movieclip to the stage

**URL:** <https://forum.kirupa.com/t/flash-as2-using-timer-to-call-movieclip-to-the-stage/330649>\
**Category:** flash\
**Created:** [February 22, 2013, 1:09am UTC](https://forum.kirupa.com/t/flash-as2-using-timer-to-call-movieclip-to-the-stage/330649 "2013-02-22T01:09:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Scholz](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@Jason\_Scholz](https://forum.kirupa.com/u/Jason_Scholz)\
**Post date:** [February 22, 2013, 1:09am UTC](https://forum.kirupa.com/t/flash-as2-using-timer-to-call-movieclip-to-the-stage/330649/1 "2013-02-22T01:09:43Z")

</div>

Here is what I am trying to implement. This is a battle screen. The scene is named Dungeon. I need this scene to randomly appear between .5 and 3 seconds. When this scene appears, A enemy will be called from the library to the main stage. However, I want the enemy to be positioned in 1 of the 6 spots. I can call the enemy to the stage by defining the specific x,y coordinates, but I want the enemy to be called to the stage to 1 of the 6 spots randomly. Here is how the stage is laid out:

[LIST]  
[_]I have 6 movieclips named: spot1, spot2, spot3, spot4, spot5, spot6  
[_]I have 1 movieclip named: enemy  
[/LIST]

Here is the code I have on the main timeline:  
stop();

hp = 100;  
eHealth = 100;

this.attachMovie(“monster1”,“monster1”,0,{\_x:100, \_y:100});  
monster1.onEnterFrame = function() {

```
monster1.onRollOver = function() {
    _root.gunman.gotoAndStop(2);
};
monster1.onRollOut = function() {
    _root.gunman.gotoAndStop(1);
};
monster1.onRelease = function() {
    if (_root.monster1.hitTest(_root._xmouse, _root._ymouse)) {
        _root.eHealth -= 10;
        _root.hp -= 5;
        gunSound = new Sound(this);
        gunSound.attachSound("Gunshot");
        gunSound.start();
    }
    if (_root.eHealth&lt;=0) {
        _root.monster1.gotoAndStop(2);
        _root.hp = 100;
    };
}

```

};

Here is what I am wanting the end result to be:

1. I need the scene Dungeon to randomly appear between .5 and 3 seconds.
2. When the Dungeon scene appears, I want the enemy to randomly appear in 1 of the 6 spots. When the enemy appears, he will stay locked into 1 of the 6 spots until the enemy is killed, or the hero is killed.

I had an early post running, however it was getting confusing, so this is a much updated and cleaner version. Thanks all for your help and support with my adventure in indie game design.

Jason D. Scholz
