# Why is this piece of code giving an error in AS2.0

**URL:** https://forum.kirupa.com/t/why-is-this-piece-of-code-giving-an-error-in-as2-0/329650
**Category:** flash
**Created:** [September 27, 2012, 6:37am UTC](https://forum.kirupa.com/t/why-is-this-piece-of-code-giving-an-error-in-as2-0/329650 "2012-09-27T06:37:43Z")
**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: [September 27, 2012, 6:37am UTC](https://forum.kirupa.com/t/why-is-this-piece-of-code-giving-an-error-in-as2-0/329650/1 "2012-09-27T06:37:43Z")

</div>

Hi all,

I picked up the following code from net and i think its and AS3 code which I am trying to run in AS2 (flash 8.0). I did create the button with remove\_bt instance as follows. The code is as follows:-

```auto
[COLOR=#0101FF]
[/COLOR]
[FONT=Verdana]var texts:Array = ['courses', 'tutorials', 'www.marplo.net']; // tex to display[/FONT]var bcolor:Array = [0xe8e9fe, 0xeded01, 0xfedada]; // Array with colors for the background of each textvar lung:int = 100; // Variable used for the lenght of the text field// Reads through the "texts" Arrayfor(var i:int=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 eventfunction removeIns(evt:MouseEvent):void{ removeChild(getChildByName('camp0')); // Deletes the element with 'camp0' name removeChild(getChildByName('camp1')); // Deletes the element with 'camp1' name [COLOR=#0101FF]}[/COLOR]

```

I get the following message :

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 29: The class or interface ‘MouseEvent’ could not be loaded.  
function removeIns(event:MouseEvent)

Total ActionScript Errors: 1 Reported Errors: 1

Can some please help sort this out.  
Thanks All.
