AS3事件侦听器时数据被改变? [英] AS3 Event listeners when data is changed?

查看:119
本文介绍了AS3事件侦听器时数据被改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望你能原谅我,如果这是一个简单的/愚蠢的问题。我开始学习动作脚本大约6天前,已经工作的一个小项目:D

Hopefully you will excuse me if this is a simple/silly question. I started learning action script about 6 days ago and already working on a small project :D

反正,有一种改变偶尔以反映在一个游戏(object._I._M.text)一个水平的名称属性。这可能需要一分钟改变,或者最多两分钟,这取决于所有球员的速度有多快能够完成的水平。

Anyways, there is a property that changes occasionally to reflect the name of a level in a game (object._I._M.text). It could take a minute to change, or a max of two minutes, depending on how fast all players are able to finish the level.

我希望能够聆听到这个属性的改变火了另一功能。我发现很少有这样的答案在网上,我已经找到了例子是非常不完整,写得不好。有谁知道我能做到这一点?

I want to be able to listen for the change in this property to fire off another function. I have found very few answers to this online, and the examples I have found were very incomplete and poorly written. Does anyone know how I could do this?

我已经试过......

I have tried ...

theobject._I._M.addEventListener(Event.CHANGE,MyFunction的);

theobject._I._M.addEventListener(Event.CHANGE, myfunction);

要没有成功。感谢您的任何帮助或建议,我要回去学习,而我在等待着回应:D

To no success. Thanks for any help or advice, I am going to get back to learning while I await responses :D

推荐答案

我可能会使用getter / setter方法​​,或者只是声明了一个方法来改变文本框的文本,以便你可以每次分派事件。

I would probably use getters/setters, or just declare one method to change the text of that textfield so that you can dispatch an event every time.

function changeLevel(text:String):void {
   levelTf.text=text;
   dispatchEvent(new Event("levelChange"));
}

这篇关于AS3事件侦听器时数据被改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆