7.1 – Add elements by code

Create a scene with a panel with variableName “panel1″ and a button with variableName “button1″.

To add a label to panel1 when button1 is clicked and change its text to “This is my new label” :

public void button1_Click(iGUIButton caller){
    iGUILabel myLabel = panel1.addElement<iGUILabel>();
    myLabel.label.text = "This is my new label";
}
function button1_Click(caller : iGUIButton){
    var myLabel = panel1.addElement("iGUILabel");
    myLabel.label.text = "This is my new label";
}