# Questions about For statement and how can I make MC run in a time I want?

**URL:** <https://forum.kirupa.com/t/questions-about-for-statement-and-how-can-i-make-mc-run-in-a-time-i-want/330603>\
**Category:** flash\
**Created:** [February 16, 2013, 11:08am UTC](https://forum.kirupa.com/t/questions-about-for-statement-and-how-can-i-make-mc-run-in-a-time-i-want/330603 "2013-02-16T11:08:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TuangPP](https://avatars.discourse-cdn.com/v4/letter/t/73ab20/32.png) [@TuangPP](https://forum.kirupa.com/u/TuangPP)\
**Post date:** [February 16, 2013, 11:08am UTC](https://forum.kirupa.com/t/questions-about-for-statement-and-how-can-i-make-mc-run-in-a-time-i-want/330603/1 "2013-02-16T11:08:56Z")

</div>

[COLOR=#333333][FONT=Verdana]Hi there, [/FONT][/COLOR]  
[COLOR=#333333][FONT=Verdana]I have been doing a game scene where MC(target) will fall from the top to the bottom of the screen. I want to make these targets to be shot, each one will fall down as a loop until in a time I want then another target will fall down …may be like 1 minute each.[/FONT][/COLOR]  
[COLOR=#333333][FONT=Verdana]It’s ok with only 1 MC but, I wan to add others to the scene. I’m using for statement to add MC and that make a function for it to ru…like this…

```auto
[/FONT][/COLOR][COLOR=#333333]for(i=1;i<=numTarget;i++){[/COLOR]

	tar=_root.attachMovie("mcTarget","t"+i,i);	tar._x=random(Stage.width);	tar._y=-random(Stage.height);	tar._xscale=random(50)+50;	tar._yscale=tar._xscale;	tar.onEnterFrame=targetRun;}function targetRun(){	if(_root.tarTimetxt>=0){ this._y+=spdTarget*(this._xscale/100); if(this._y>Stage.height){ this._x=random(Stage.width); this._y=-this._height;	}	} if(_root.tarTimetxt>=10){ for(i=1;i<=numTarget;i++){ delete _root["t"+i].onEnterFrame; _root["t"+i].removeMovieClip(); }	} [COLOR=#333333]}[/COLOR][COLOR=#333333][FONT=Verdana]

```

[/FONT][/COLOR][COLOR=#333333][FONT=Verdana]I have tried many ways to create another mc such as[/FONT][/COLOR]  
[COLOR=#333333][FONT=Verdana]I created a new scene so everything will be like fresh start but, still didn’t work very well.[/FONT][/COLOR]  
[COLOR=#333333][FONT=Verdana]I created another FOR in the same frame and add another function, used all different variables. a,b,c,d,…[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]So the questions are…[/FONT][/COLOR]  
[COLOR=#333333][FONT=Verdana]1)this for statement can be more than one in the same frame? or I can only use one, if YES then how can I add another MC to the scene.[/FONT][/COLOR]  
[COLOR=#333333][FONT=Verdana]2) Is there any better ways else to create thing like I want just MC which is a target to shoot fall down in a time I want ?[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]OH! the shooting code I use is like this…

```auto
[/FONT][/COLOR][COLOR=#333333]function ballRun(){[/COLOR]

	this._x+=this.spdX;	this._y+=this.spdY;	for(i=1;i<=numTarget;i++){ tar=_root["t"+i]; if(this.hitTest(tar)){ if(tar._currentframe==1){ tar.play(); this.removeMovieClip(); } }	} [COLOR=#333333]}[/COLOR][COLOR=#333333][FONT=Verdana]

```

[/FONT][/COLOR][COLOR=#333333][FONT=Verdana]3) Do I have to created function sm/thg like ballRun every MC I change?[/FONT][/COLOR]

:puzzle::puzzle::puzzle:  
[COLOR=#333333][FONT=Verdana]Thanks in Advance.[/FONT][/COLOR]:beam:
