# Why is this code not working in AS3

**URL:** https://forum.kirupa.com/t/why-is-this-code-not-working-in-as3/329734
**Category:** Uncategorized
**Created:** [October 8, 2012, 11:34am UTC](https://forum.kirupa.com/t/why-is-this-code-not-working-in-as3/329734 "2012-10-08T11:34:45Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ajoo](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@ajoo](https://forum.kirupa.com/u/ajoo)
#### Post date: [October 8, 2012, 11:34am UTC](https://forum.kirupa.com/t/why-is-this-code-not-working-in-as3/329734/1 "2012-10-08T11:34:45Z")

</div>

[COLOR=#333333][FONT=Segoe UI]Hi all. I tried this piece of code given below in CS3. I got the error listed below the code and there is nothing drawn on the screen. [/FONT][/COLOR]

I have created a DEL button on stage. Other than that the text fields do not dwar on stage.

```auto
var texts:Array = ['courses', 'tutorials', 'www.marplo.net']; // Array with text to displayvar bcolor:Array = [0xe8e9fe, 0xeded01, 0xfedada]; // Array with colors for the background of each text
var lung = 100; // Variable used for the lenght of the text field

// Reads through the "texts" Array
for(var i=0; i<texts.length; i++)
{
  // creates a field "TextField" for each element in texts
  // Sets the fields height, lenght, and distance "x" depending on "i" (for liniar display)
  // Adds background color from "bcolor" Array and text from the current element in "texts"
  var txt:TextField = new TextField();
  txt.height = 25;
  txt.width = lung;
  txt.x = i*(lung + 8);
  txt.backgroundColor = bcolor*;
  txt.background = true;
  txt.text = texts*;

  // Atributin a name to the instance, for it to be unique also use 'i's value
  txt.name = 'camp'+i;

  addChild(txt); // Adds the field on the stage
}

// Recording CLICK event for the button on the stage, "remove_bt"
remove_bt.addEventListener(MouseEvent.CLICK, removeIns);

// The function called by the registered event
function removeIns(event:MouseEvent)
{
  removeChild(getChildByName('camp0')); // Deletes the element with 'camp0' name
  removeChild(getChildByName('camp1')); // Deletes the element with 'camp1' name
}

```

[COLOR=#333333][FONT=Segoe UI]  
Can someone help me resolve this? Thanks to all.[/FONT][/COLOR]
