# Custom component problem

**URL:** https://forum.kirupa.com/t/custom-component-problem/285544
**Category:** flash
**Created:** [April 2, 2009, 5:14am UTC](https://forum.kirupa.com/t/custom-component-problem/285544 "2009-04-02T05:14:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![balajee](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@balajee](https://forum.kirupa.com/u/balajee)
#### Post date: [April 2, 2009, 5:14am UTC](https://forum.kirupa.com/t/custom-component-problem/285544/1 "2009-04-02T05:14:48Z")

</div>

I created a simple component in AS 3.0 and the component in main .fla file i just click the component and throws the following errors (automatically declare stage instances are unchecked)…[SIZE=“5”][COLOR=“Red”]but the component is working fine[/COLOR][/SIZE]  
all the classes are imported and type identifier is also included

[COLOR=“SlateGray”]Line 1: Syntax error.  
package {  
Line 12: Attribute used outside class.  
public class MyButton extends Sprite {  
Line 14: The class or interface ‘flash.display.Sprite’ could not be loaded.  
public var container:Sprite;  
Line 15: The class or interface ‘flash.display.Sprite’ could not be loaded.  
public var mcOver:Sprite;  
…  
Line 46: A type identifier is expected after the ‘:’.  
private function clipDraw():void {[/COLOR]

and finally

[COLOR=“DarkRed”]Line 75: ActionScript 2.0 class scripts may only define class or interface constructs.  
}  
[/COLOR]

and i attached the source files  
please help me and explain what is actual problem?

[SIZE=“7”][COLOR=“DarkRed”]Source code [/COLOR][/SIZE]

package {

```
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.MouseEvent;

public class MyButton extends Sprite {
	
	public var container:Sprite;
	public var mcOver:Sprite;
	public var mcNormal:Sprite;
	private var _widt:Number = 0;
	private var _heigh:Number = 0;
	
	public function MyButton() {
		init();
		childrens();
		clipDraw();
	}
	
	private function init():void {
		_widt = width;
		_heigh = height;
		scaleX = 1;
		scaleY = 1;
		removeChildAt(0);
	}
	
	private function childrens():void {
		container = new Sprite();
		mcNormal = new normal();
		mcOver = new over();
		buttonMode = true;
		addChild(container)
		container.addChild(mcNormal);
		//addChild(mcOver);
		//mcOver.visible = false;
		clipDraw();
	}
	
	private function clipDraw():void {
		container.width = _widt;
		container.height = _heigh;
		
		container.addEventListener(MouseEvent.MOUSE_OVER, onOver);
		container.addEventListener(MouseEvent.MOUSE_OUT, onOut);
	}
	
	public function setSize(w:Number,h:Number):void {
		_widt = w;
		_heigh = h;
		clipDraw();
	}
	
	private function onOver(m:MouseEvent):void {
		//trace(container);
		container.removeChildAt(0);
		container.addChild(mcOver);
	}
	
	private function onOut(m:MouseEvent):void {
		container.removeChildAt(0);
		container.addChild(mcNormal);
		
		
	}
	
}

```

}
