# Creating a for loop to create dynamic variables

**URL:** <https://forum.kirupa.com/t/creating-a-for-loop-to-create-dynamic-variables/316955>\
**Category:** flash\
**Created:** [December 6, 2010, 8:26pm UTC](https://forum.kirupa.com/t/creating-a-for-loop-to-create-dynamic-variables/316955 "2010-12-06T20:26:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ektorp](https://avatars.discourse-cdn.com/v4/letter/e/87869e/32.png) [@ektorp](https://forum.kirupa.com/u/ektorp)\
**Post date:** [December 6, 2010, 8:26pm UTC](https://forum.kirupa.com/t/creating-a-for-loop-to-create-dynamic-variables/316955/1 "2010-12-06T20:26:37Z")

</div>

I have the code below but I need to generate it with a for loop. What is the proper way to do this? I don’t initially know how many points i will have. I just want to create a for loop to loop through a variable that holds the point count such as “var totalPoints=10” … any help would be greatly appreciated.

//1  
var p1:Point = new Point();  
points.addChild(p1);  
p1.x = points.tickX.getChildByName(“x100”).x \* .935;  
p1.y = (points.height - xmlData.model[modelID].performance.flightPlanning.Dist[0].time) \* 1.02;

//2  
var p2:Point = new Point();  
points.addChild(p2);  
p2.x = points.tickX.getChildByName(“200”).x \* .935;  
p2.y = (points.height - xmlData.model[modelID].performance.flightPlanning.Dist[1].time) \* 1.02;

//3  
var p3:Point = new Point();  
points.addChild(p3);  
p3.x = points.tickX.getChildByName(“x300”).x \* .935;  
p3.y = (points.height - xmlData.model[modelID].performance.flightPlanning.Dist[2].time) \* 1.02;

//4  
var p4:Point = new Point();  
points.addChild(p4);  
p4.x = points.tickX.getChildByName(“x400”).x \* .935;  
p4.y = (points.height - xmlData.model[modelID].performance.flightPlanning.Dist[3].time) \* 1.02;
