0

In my class, I built a Weather VO (Visual Object) and now need to use it for another class. How would I use it to modify the values of the text field in my second class? I attempted using getters and setters to no avail.

First Page:

vo=new WeatherVO();//Visual Object for the weather data
    vo.city = _xmlData.channel.ns1::location.@city+", "+_xmlData.channel.ns1::location.@region;//city, st
    vo.currentTemp = _xmlData.channel.item.ns1::condition.@temp;
    vo.currentCondition = _xmlData.channel.item.ns1::condition.@text;
    vo.currentCode = _xmlData.channel.item.ns1::condition.@code;
    vo.sunrise = _xmlData.channel.ns1::astronomy.@sunrise;
    vo.sunset = _xmlData.channel.ns1::astronomy.@sunset;

Second page:

    public function set vo(value:WeatherVO):void
    {
        _weather=value;
    }

    public function get vo():WeatherVO
    {
        return _weather;
    }
Andreas
  • 417
  • 2
  • 5

1 Answers1

0

Your getters and setters should be methods of the WeatherVO class that aid in the modification and retrieval of properties within that class. With the limited code sample you have provided, my recommendation is to pass the weather data through your WeatherVO constructor like so.

public function WeatherVO(_city:String, _currentTemp:String, _currentCondition:String, _currentCode:String, _sunrisde:String, _sunset:String) {
    city = _city;
    currentTemp = _currentTemp;
    currentCondition = _currentCondition;
    currentCode = _currentCode;
    sunrise = _sunrise;
    sunset = _sunset;
}

//Here is an example getter and setter for the city value.
public function get City() {
    return city;
}

public function set City(_city:String) {
    city = _city;
}
Andreas
  • 417
  • 2
  • 5