# Need help about Actionscript3 code

**URL:** <https://forum.kirupa.com/t/need-help-about-actionscript3-code/264512>\
**Category:** flash\
**Created:** [June 26, 2008, 7:13pm UTC](https://forum.kirupa.com/t/need-help-about-actionscript3-code/264512 "2008-06-26T19:13:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pantsie](https://avatars.discourse-cdn.com/v4/letter/p/e47774/32.png) [@Pantsie](https://forum.kirupa.com/u/Pantsie)\
**Post date:** [June 26, 2008, 7:13pm UTC](https://forum.kirupa.com/t/need-help-about-actionscript3-code/264512/1 "2008-06-26T19:13:34Z")

</div>

Hello there! I need to make a mini game for school in Actionscript 3. Everything seemed to go fine… till I needed a certain code x) I tried to search and search… but couldn’t find it anywhere 😑

**My problem:**  
I have a frame which loads random pictures of a certain folder. But I want the frame to last just a few seconds… like about 5 and then go to the next frame. And however I didn’t use a stop function… this frame still doesn’t go automatically to the next one.

I hope one of you know how to fix this problem… Thanks in advance 🙂

> 

**My actionscript:**

var imageArray:Array = new Array(10);  
imageArray[0] = “Randomdoll/Outfit1.jpg”;  
imageArray[1] = “Randomdoll/Outfit2.jpg”;  
imageArray[2] = “Randomdoll/Outfit3.jpg”;  
imageArray[3] = “Randomdoll/Outfit4.jpg”;  
imageArray[4] = “Randomdoll/Outfit5.jpg”;  
imageArray[5] = “Randomdoll/Outfit6.jpg”;  
imageArray[6] = “Randomdoll/Outfit7.jpg”;  
imageArray[7] = “Randomdoll/Outfit8.jpg”;  
imageArray[8] = “Randomdoll/Outfit9.jpg”;  
imageArray[9] = “Randomdoll/Outfit10.jpg”;

voegtoe();

function voegtoe(){  
var plaatje:MovieClip = new mClip();  
plaatje.x = 50;  
plaatje.y = 100;  
plaatje.img.source = imageArray[Math.round(Math.random()\*(imageArray.length-1))];  
addChild(plaatje);  
}

---

<div class="post-metadata">

**Author:** ![Lachhh](https://avatars.discourse-cdn.com/v4/letter/l/f0a364/32.png) [@Lachhh](https://forum.kirupa.com/u/Lachhh)\
**Post date:** [June 27, 2008, 12:37pm UTC](https://forum.kirupa.com/t/need-help-about-actionscript3-code/264512/2 "2008-06-27T12:37:17Z")

</div>

You could try :

```auto

 
var WAIT_FRAME:int = 360 //6 seconds at 60 FPS 
var cpt:int = 0 ;
function Wait(pEvent:Event):void {
     if(cpt++ > WAIT_FRAME) {
          play(); //Or gotoAndPlay(), whatever
          removeEventListener(ENTER_FRAME, Wait);
     }
}
addEventListener(ENTER_FRAME, Wait);
stop();

```
