# Tiding instance variables with constructor arguments

**URL:** <https://forum.kirupa.com/t/tiding-instance-variables-with-constructor-arguments/303918>\
**Category:** flash\
**Created:** [January 28, 2010, 11:46pm UTC](https://forum.kirupa.com/t/tiding-instance-variables-with-constructor-arguments/303918 "2010-01-28T23:46:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fs\_tigre](https://avatars.discourse-cdn.com/v4/letter/f/edb3f5/32.png) [@fs\_tigre](https://forum.kirupa.com/u/fs_tigre)\
**Post date:** [January 28, 2010, 11:46pm UTC](https://forum.kirupa.com/t/tiding-instance-variables-with-constructor-arguments/303918/1 "2010-01-28T23:46:25Z")

</div>

Hi,

I know this is probably a question with a long answer but I would like someone from here to explain this a little bit, believe or not I have read Essential Actionscript 3.0 and Learning Actionscript 3.0 and still confused (I know I know but I want to keep trying).

I know what instance variables, contractor methods, local variables and constructor arguments are (I think) but I’m confused as to when or how to use them, for instance I have use this a lot and I don’t really understand why it is used like this…

[AS] package standard.testing {

```
import flash.display.MovieClip;
import flash.events.Event; 
import com.greensock.*;

public class TweenIt extends MovieClip{
	public var _mc = MovieClip;
	public var _xPos= Number;
	public var _yPos = Number;
	
	public function TweenIt(){
		// do nothing
	}
	
	public function tweenMe(mc:MovieClip, xPos:Number, yPos:Number){
		_mc = mc;
		_yPos = yPos;
		_xPos = xPos;
		
		addEventListener(Event.ENTER_FRAME, tweenIt);
	}
	
	public function tweenIt(event:Event):void{
		TweenLite.to(_mc,1,{x:_xPos, y:_yPos});
	}
}

```

}  
[/AS]

Why create a function with arguments…

[AS]public function tweenMe(mc:MovieClip, xPos:Number, yPos:Number)[/AS]

Then create instance variables…

[AS]  
public var \_mc = MovieClip;  
public var \_xPos= Number;  
public var \_yPos = Number  
[/AS]

then create local variables with the values of the arguments

[AS]  
\_mc = mc;  
\_yPos = yPos;  
\_xPos = xPos;[/AS]

I know this is probably hard to explain but please do your best.

Thanks a lot!
