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!