我无法使此代码在包含 Flex SDK 4.0 的 AS3.0 ( Flash ) 中工作。
import mx.binding.utils.*;
[Bindable]
var myValue:int = 0;
var cw:ChangeWatcher = BindingUtils.bindSetter(myValueChanged, this, "myValue");
addEventListener( Event.ENTER_FRAME , ef);
function ef(e:Event):void
{
trace("hello",getTimer());
myValue = getTimer();
}
function myValueChanged(o:Object):void
{
trace("myValue: " + myValue.toString());
}
我得到的输出是:
myValue: 0
hello 157
hello 168
hello 171
hello 177
....
....
等等。
但我预计正确的输出应该是:
myValue: 0
hello 157
myValue: 157
hello 168
myValue: 168
hello 171
myValue: 171
hello 177
myValue: 177
....
....
Thanks.
数据绑定仅适用于 Flex。
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" enterFrame="ef(event)">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.binding.utils.*;
[Bindable]
public var myValue:int = 0;
private var cw:ChangeWatcher = BindingUtils.bindSetter(myValueChanged, this, "myValue");
private function ef(e:Event):void
{
trace("hello", getTimer());
myValue = getTimer();
}
private function myValueChanged(o:Object):void
{
trace("myValue: " + myValue.toString());
}
]]>
</fx:Script>
</s:WindowedApplication>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)