# Works just in constructor function

**URL:** <https://forum.kirupa.com/t/works-just-in-constructor-function/302808>\
**Category:** flash\
**Created:** [January 7, 2010, 7:44pm UTC](https://forum.kirupa.com/t/works-just-in-constructor-function/302808 "2010-01-07T19:44:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kustrle](https://avatars.discourse-cdn.com/v4/letter/k/8e7dd6/32.png) [@kustrle](https://forum.kirupa.com/u/kustrle)\
**Post date:** [January 7, 2010, 7:44pm UTC](https://forum.kirupa.com/t/works-just-in-constructor-function/302808/1 "2010-01-07T19:44:34Z")

</div>

Okay, lets get to my problem. If I pass variable(s) like this in document class action script file(I’m not even sure if I can pass more than one variable):

```auto
ballPointRight = new BallPointRight(ball, xDir, padScreen) ;

```

And now the BallPointRight’s action script file:

```auto
package {
	import flash.display.MovieClip;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	public class BallPointRight extends MovieClip {
		public var ball:Ball;
		public var xDir:Number;
		public var padScreen:PadScreen;
		public var timerRightPoint:Timer;
		public function BallPointRight(ball:Ball, xDir:Number, padScreen:PadScreen) {
			timerRightPoint = new Timer(10);
			timerRightPoint.addEventListener(TimerEvent.TIMER,mainRightPoint);
			timerRightPoint.start();
		}
		public function mainRightPoint(timerEvent:TimerEvent):void {
			this.x = ball.x;
			this.visible = false;
			if (PixelPerfectCollisionDetection.isColliding(this,padScreen,this.parent,true) || this.x >= 550) {
				xDir = -1;
			}
		}
	}
}

```

Okay so here it seems that if I specify variables in constructor function

```auto
(ball:Ball, xDir:Number, padScreen:PadScreen)

```

then I can just use them inside constructor function. But I can’t use them inside other functon (mainRightPoint)? So how could I make it work. Now the

```auto
this.x = ball.x;
			this.visible = false;
			if (PixelPerfectCollisionDetection.isColliding(this,padScreen,this.parent,true) || this.x >= 550) {
				xDir = -1;
			}

```

doesnt work since it doesnt recognize variables…
