在我的类中,我构建了一个天气VO (Visual ),现在需要将它用于另一个类。如何使用它来修改第二个类中文本字段的值?我试图使用getter和setter,但没有效果。
首页:
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;第二页:
public function set vo(value:WeatherVO):void
{
_weather=value;
}
public function get vo():WeatherVO
{
return _weather;
}发布于 2013-08-17 18:17:16
您的getter和setter应该是WeatherVO类的方法,它们帮助修改和检索该类中的属性。使用您提供的有限代码示例,我的建议是通过WeatherVO构造函数传递天气数据,如下所示。
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;
}https://stackoverflow.com/questions/18289519
复制相似问题