The below code is for generating a star pattern in AS 3.0. First from the components drag the TextArea component to the stage. Then give it an instance name txt.

var lines:int = 5;
var star:String = "*";
var space:String = " ";
 
var i:int;
var j:int;
var k:int;
var str:String = "";
 
function init():void
{
    /* Upper Triangle */
    for(i = 0; i < lines; i++) {
        j = i;
        str = "";
        for(k = 0; k < 5-i; k++) {
            str += space;
        }
        while(j != 0) {   
            str += star + space;
            j--;
        }
        txt.text += str + "\n";
    }
 
    /* Lower Triangle */
    for(i = lines; i != 0; i--) {
        j = i;
        str = "";
        for(k = 0; k < 5-i; k++) {
            str += space;
        }
        while(j != 0) {   
            str += star + space;
            j--;
        }
        txt.text += str + "\n";
    }
}
 
init();
//Output
    * 
   * * 
  * * * 
 * * * * 
* * * * * 
 * * * * 
  * * * 
   * * 
    * 
The idea behind this

It is easier to think with lower triangle taken first. For the time being let's consider that we need only the lower triangle. i.e, say there will be 5 lines, and in the first line there will be 5 stars, in the second line there will be 4 stars and so on.

Think that if we simply put a for loop with the number of lines (5) and decrement it, in the first iteration we get 5, second iteration 4, which is the number of stars we need to show per line. Now what we need is to actually display those number of stars.

The idea is concatenate those number of stars into a string and display them. Now what we get is a right angled triangle. That's because we need to concatenate the correct space along with the string. That's what the for loops in line number 16 and 30 does.

Now we have required triangle. Upper triangle can be constructed by changing the looping. You can easily make a recursive version if you would like.