- 浏览: 11904 次
最新评论
Flex中的set啊Flex中的set
2010年10月17日
Flex中的set function就是给属性赋值的,说起来简单,但是遇到一个相关的bug还真晕。其实几天前就遇到类似问题了,我没有深究,赶进度嘛。今天晚上Alan修一个bug的时候又遇到了,作为小leader,我就得帮他解惑。正好自己也研究下,就算晚上没白等QA做build了。刚刚又上网找了找,还真没类似的文章,那我这个算原创了吧?哇咔咔……和大家分享吧,说不定有谁遇到类似的问题,痛苦半天呢。(已经知道答案的也不要鄙视我,毕竟我也是新手不是?)
问题:Flex中的set在什么情况下不起作用?
言归正传,先说说这个问题的由来吧:
ModelLocator.getInsternce().buildModel.selectedBui ldVo = vo;
就是代码中的这句话,设了断点怎么也跑不进去(selectedBuildVo是一个set function)在这个set中,有一点逻辑来处理vo中的一些数据的,从而改变绑定在页面上的一个对象。
不绕弯子了,上面那个问题的答案是:当set中的值在内存中的地址和所要赋值的对象的地址一样时,也就是说,selectBuildVo和vo的地址一样时(同一个对象),这个set不起作用,当然,set中的逻辑也不会跑起来。这个和函数还是不一样的,function的话,什么时候调用,什么时候就会老老实实去跑的……
同时,让我郁闷的是,第一次遇到这样的情况,原来没一点类似经验啊,根本不会往这个地方想,呵呵。教条主义害死人啊,谁也没和我数过给一个set function赋值的时候一定会跑进去啊。看来以后还是需要多用方法,别什么都省事,想用set function来实现。
作为一种习惯,我顺带把这个问题和.net中的set对比了一下,发现Flex的set和.net的set还真不一样,哈哈,.net中的set,无论什么时候赋值,都会乖乖响应的……
============================
下面贴出证明上述结论的codes,先.net吧:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class TestVo
{
public TestVo() { }
public string test = "TEST";
}
class Program
{
static TestVo _vo1;
static TestVo vo1
{
get { return _vo1; }
set { Console.WriteLine("Call SET"); _vo1 = value; }
}
static void Main(string[] args)
{
TestVo vo2 = new TestVo();
Console.WriteLine("Try first set, this time the address are NOT same");
vo1 = vo2;
vo2.test = "test2";
Console.WriteLine("Try second set, this time the address are same");
vo1 = vo2;
Console.ReadKey();
}
}
}
下面是Flex的demo:
TestVo.as文件:
package
{
[Bindable]
public class TestVo extends Object
{
public functionTestVo()
{
}
varpublic var test:String="TEST";
}
}
TrySet.mxml文件:
flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()">
发表评论
-
字符串内建函数
2012-07-06 09:52 600>>> quest='what ... -
js+正文规则 高亮搜索关键字(二)
2012-07-06 09:46 71511 我顶 用户通过搜索引擎搜索关键字进入你的网站或者 ... -
TWaver Flex与.net最新版,三大视图组件齐备
2012-07-03 13:44 819TWaver Flex与.NET最新版,三大视图组件齐 ... -
flash特效原理:标签云
2012-07-02 13:13 659其实标签云是一个比较常见的特效类,在wondefl里 ... -
Flex: flash聊天框 表情+文字 图文混排 (思路)
2012-07-02 13:13 848flash聊天框 表情+文字 图文混排 (思路) s ... -
Flex 4(Hero)对应Flex 3 容器方法
2012-07-02 13:13 570Spark容器 Halo容器 说明 numElem ... -
项目启动异常:Exception: java.lang.RuntimeException: XPathFactory#newInstance()
2012-07-02 13:12 1651项目启动时,报如下异常: **** MessageBrok ... -
Flex中datagrid动态添加列
2012-07-02 13:12 682addChild(dataGrid ... -
flex4:中DataGroup组件获取数据源(ArrayCollection方式)实例
2012-07-01 10:44 641flex/spark" xmlns:mx=&q ... -
flex--LineChart
2012-07-01 10:44 587最近工作上用到了linechart,在网上查的资料还是非常 ... -
Flex 动态创建 多个曲线图/柱形图 ColumnSeries
2012-07-01 10:44 698获取数据后的回调函数 private functio ... -
A Way to implement Abstract Class In Flex
2012-07-01 10:44 652A Way to implement Abstract C ... -
flex cairngorm项目实战
2012-07-01 10:44 503项目功能与界面模仿阿布网站 系统功能: 新闻管 ... -
Flex 拖拽范例
2012-06-30 17:08 498Flex 拖拽范例 2011年03月09日 Flex由于 ... -
Flex和Java 整合
2012-06-30 17:08 550Flex和Java 整合 2010年07月21日 Fle ... -
Flex FTP文件上传
2012-06-30 17:08 761Flex FTP文件上传 2010年10月10日 Fle ...
相关推荐
flex例程一,好不容易找到的。关于如何建GET,SET关于如何建GET,SET
flex 生成geter seter 工具,简单实用。无需安装,swf 格式,方便实用。
在Flex中嵌入完整的网页所用到的类, xmlns:flexiframe="com.google.code.flexiframe.*" <flexiframe:IFrame id="helpFrame" source="assets/dreamweaver/help/helpHome....
4. In Adobe Flash Builder, right-click on any of the sample mxml applications and click "Set as Default Application". 5. In Adobe Flash Builder, right-click on any of the sample mxml applications and...
因此,需要一个 FactoryInstance 的实现类,我们编写一个 SpringFactoryInstance,以便从 Spring 的容器中查找 FlexService: 清单 9. SpringFactoryInstance class class SpringFactoryInstance extends ...
This latest edition includes complete coverage of new Flex 4.5 features, such as new enhancements to the Spark architecture and component set. It will also show you how to take advantage of the ...
因此,需要一个 FactoryInstance 的实现类,我们编写一个 SpringFactoryInstance,以便从 Spring 的容器中查找 FlexService: 清单 9. SpringFactoryInstance class class SpringFactoryInstance extends ...
把下载的jar包放在 Maven仓库的 org\mybatis\generator\mybatis-generator-core\1.3.5 下面即可,然后在generatorConfig配置文件中加上 </plugin> 即可
mql 4 forex flex ea. including indicators and set files
This chapter makes the case why Flex is a great addition to your personal skill set or your organization. With buzzwords flying all over, a nonstop stream of websites with missing vowels in their ...
4. In Adobe Flash Builder, right-click on any of the sample mxml applications and click "Set as Default Application". 5. In Adobe Flash Builder, right-click on any of the sample mxml applications and...
4. In Adobe Flash Builder, right-click on any of the sample mxml applications and click "Set as Default Application". 5. In Adobe Flash Builder, right-click on any of the sample mxml applications and...
flex跨域上传,需nginx,tomcat host: 127.0.0.1 test1.zwh.com 127.0.0.1 test2.zwh.com nginx: client_max_body_size 2048m; server { listen 80; server_name test2.zwh.com; location / { proxy_set_...
4. In Adobe Flash Builder, right-click on any of the sample mxml applications and click "Set as Default Application". 5. In Adobe Flash Builder, right-click on any of the sample mxml applications and...
4. In Adobe Flash Builder, right-click on any of the sample mxml applications and click "Set as Default Application". 5. In Adobe Flash Builder, right-click on any of the sample mxml applications and...
4. In Adobe Flash Builder, right-click on any of the sample mxml applications and click "Set as Default Application". 5. In Adobe Flash Builder, right-click on any of the sample mxml applications and...
4. In Adobe Flash Builder, right-click on any of the sample mxml applications and click "Set as Default Application". 5. In Adobe Flash Builder, right-click on any of the sample mxml applications and...
sheet.setCell(0, 0, "Today's date:"); sheet.setCell(0, 1, new Date()); excelFile.sheets.addItem(sheet); var mbytes:ByteArray = excelFile.saveToByteArray(); var stream:FileStream = new ...
flex DataGrid 导出Xls private function insertRecordInSheet(row:int,sheet:Sheet,record:Object):void { var colCount:int = rebateByItemDG.columnCount; for(var c:int; c ; c++) { var i:int = 0; ...
as get set类生成工具,简单实用!