Need way to delay execution

I just need a simple way for flash to delay the execution of a group of actions for a few seconds.

Here is the code I need delayed:

_root.randomnumber=(random(20))

if (_root.randomnumber<=8){_root.commentbox=“Hit!”}

if (_root.randomnumber<=8){_root.enemyhp-=15, nextFrame()
}

else {_root.commentbox=“Miss!”
}

just make a mvc to the left of your stage… you know you will make it 12 frames long and on the last key frame put an add AS:
_root.num += 1
and then on that movie clip put the:
onClipEvent(EnterFrame) {
if (_root.num == 12) {
goto and play(number)
}
}
Note: thats a rough example dont copy the code.

i cant do that becuase I need to acess code outside of the movie clip and I dont think that will work… Unless I’m meiss understanding what you are saying

it doesnt matter its used more for multiple waiting times that takes like no space up

or simply wrap the code you want delayed with this:

waitV=setInterval(function(){
    clearInterval(waitV)
    ...
    the code you want delayed
    ...
},x) //where x is the number of milliseconds you want it delayed for

ill wrap it around your code so you can see what i mean and ill make it wait for 5 secs:

waitV=setInterval(function(){
    clearInterval(waitV)
    _root.randomnumber=(random(20))
    if (_root.randomnumber<=8){_root.commentbox="Hit!"}
    if (_root.randomnumber<=8){_root.enemyhp-=15, nextFrame()
    }
    else {_root.commentbox="Miss!"
    }
},5000)

Prophet.