首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在类之间的actionscript中使用VO

在类之间的actionscript中使用VO
EN

Stack Overflow用户
提问于 2013-08-17 13:48:57
回答 1查看 88关注 0票数 0

在我的类中,我构建了一个天气VO (Visual ),现在需要将它用于另一个类。如何使用它来修改第二个类中文本字段的值?我试图使用getter和setter,但没有效果。

首页:

代码语言:javascript
复制
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;

第二页:

代码语言:javascript
复制
    public function set vo(value:WeatherVO):void
    {
        _weather=value;
    }

    public function get vo():WeatherVO
    {
        return _weather;
    }
EN

回答 1

Stack Overflow用户

发布于 2013-08-17 18:17:16

您的getter和setter应该是WeatherVO类的方法,它们帮助修改和检索该类中的属性。使用您提供的有限代码示例,我的建议是通过WeatherVO构造函数传递天气数据,如下所示。

代码语言:javascript
复制
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;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18289519

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档