I’m studying get set and I’m a little stuck.
in the example i’m studying the controller class detects keyboard input with a switch
standard example…
case Keyboard.LEFT:
model.direction = "Left" ;
break;
then over in the model class we have…
public function get direction():String
{
return_direction;
}
public function set direction(value:String):void
{
_direction=value;
dispatchEvent(new Event(Event.CHANGE));
}
then it shoots over to the view class
public function changeHandler(event:Event):void
{
_status.text=_model.detection;
}
let me get to my confusion. I don’t understand the flow through the model class’s get set. To me it looks like control sends “Left” to
public function set direction(value:String):void
{
_direction=value;
dispatchEvent(new Event(Event.CHANGE));
}
sets _direction to value(in this case Left) shoots off change ,which lets view know its time to set _status.text to _modelDirection(in this case Left)
why do we even NEED
public function get direction():String
{
return_direction;
}
and who is it returning that value to?
please illuminate!!!