# Delay action by frames

**URL:** <https://forum.kirupa.com/t/delay-action-by-frames/38812>\
**Category:** flash\
**Created:** [December 30, 2003, 3:18am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812 "2003-12-30T03:18:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamer](https://avatars.discourse-cdn.com/v4/letter/d/6bbea6/32.png) [@dreamer](https://forum.kirupa.com/u/dreamer)\
**Post date:** [December 30, 2003, 3:18am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812/1 "2003-12-30T03:18:27Z")

</div>

How do you delay an action until a certain number of frames?  
on (release) {  
play();  
function loadIn(movie) {  
content.loadMovie(movie);  
clearInterval(loadInterval);  
}  
loadInterval = setInterval(loadIn, 200, “musical/interviews/peteteo/peteteo.swf”);  
}

This is the code for milliseconds, however, its not efective.

any clues?

---

<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:** [December 30, 2003, 3:23am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812/2 "2003-12-30T03:23:34Z")

</div>

You can use the movieclip.\_currentframe property.

---

<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:** [December 30, 2003, 3:37am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812/3 "2003-12-30T03:37:09Z")

</div>

how does that work?

---

<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:** [December 30, 2003, 3:38am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812/4 "2003-12-30T03:38:59Z")

</div>

You can retrieve the movieclip’s current frame.  
What exactly you want to do?

---

<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:** [December 30, 2003, 3:57am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812/5 "2003-12-30T03:57:04Z")

</div>

this code which i’m using now is:  
on (release) {  
play();  
function loadIn(movie) {  
content.loadMovie(movie);  
clearInterval(loadInterval);  
}  
loadInterval = setInterval(loadIn, 200, “musical/interviews/peteteo/peteteo.swf”);  
}

What this does is that once the button is clicked on the action will not happen until 200 milliseconds later.

Instead of 200 miliseconds how do i make that 30 frames?

---

<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:** [December 30, 2003, 5:56am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812/6 "2003-12-30T05:56:07Z")

</div>

why do you want it 30 frames? How is your movie set up?

---

<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:** [December 30, 2003, 6:14am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812/7 "2003-12-30T06:14:16Z")

</div>

its just an example. i want to put any frame value in it.

---

<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:** [December 30, 2003, 6:15am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812/8 "2003-12-30T06:15:28Z")

</div>

i don’t want to use time as the counter. instead i want to use frames as the counter. eg.

when this button is click on the action will not happen until 30 frames later.

---

<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:** [December 30, 2003, 10:47am UTC](https://forum.kirupa.com/t/delay-action-by-frames/38812/9 "2003-12-30T10:47:55Z")

</div>

Something like this (be careful not to erase anything with the onEnterFrame):

```auto
on (release) {
play();
this.onEnterFrame = function () {
// this will overwrite the onEnterFrame of the timeline containing the button
this.i++;
if (this.i == 30) {
content.loadMovie("musical/interviews/peteteo/peteteo.swf");
delete this.onEnterFrame;
}
}
}

```

pom 🙂
