문제

Say I have a parent- and a child-object. At some point a variable (boolean) in the child changes and the parent needs to notice. Now, is it performance-wise cheaper to let the child dispatch an event once the variable has changed, or to have the parent check this childs variable every frame in an already existing enterFrameEventHandler?

도움이 되었습니까?

해결책

It is right. Event over loop check. But event better would be a callback. The event generation is heavy. If your variable or whatever changes quite often, then you would create a new Event instance every time a change happens.

Rob Penner wrode the library signals because of this problem:

https://github.com/robertpenner/as3-signals

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top