[Laszlo-dev] Generic notifying events [Was: For Review: Change 20090427-hqm-Q Summary: fix for swf9 context menus, mouseEnabled no longer always set to true on every sprite]
P T Withington
ptw at pobox.com
Tue Apr 28 14:49:34 PDT 2009
On 2009-04-28, at 16:38EDT, Max Carlson wrote:
> P T Withington wrote:
>> On 2009-04-28, at 16:16EDT, Max Carlson wrote:
>>>> So all you have to do is make your own declared event instance to
>>>> initialize your event to, you don't have to make a separate class.
>>>
>>> How would this work in declarative syntax?
>> Give me an example of where you would need it and I will tell you.
>> The only places I could think of using this is internally when
>> connecting events to the runtime, because the runtime only accepts
>> callbacks and you would like to not register a callback that is
>> going to be a no-op because the corresponding event is not ready.
>> In declarative code, setAttribute is already optimized to do
>> nothing if the corresponding event is not ready.
Well, just in case, we could do something like this:
<class name="myFunnyEventine" extends="event">
<method name="onReadyChange" args="newValue">
if (newValue) {
// you have listeners...
} else {
// now you don't...
}
</method>
</class>
<event name="sometimesMaybe" type="myFunnyEventine" />
And the event compiler would compile that to:
var sometimesMaybe = new LzDeclaredEvent(myFunnyEventime);
And you're done. Power tool, use with extreme caution.
---
Anyone got a better name than `onReadyChange`?
More information about the Laszlo-dev
mailing list