View Full Version : How did MM add event handlers to the "on(" clause (MC instance script) ??
Hi All!
I see that all MX components in their instance action script window (click on instance and open the Actions window) allow not only the usual documented "onRelease, onReleaseOutside, onPress" etc events, but also the new event model events like "load", "draw", "move" etc. How does the technic work ? I.e. how do these actions route further to a custom action script ? I dont see any facility which lets me override the "on (...)" script syntax, nor do I see how can a programmer add his/her own events ...
Am I missing something ?
sleekdigital
07-14-2005, 03:00 PM
The "on(...)" is not syntax, its just a naming convention. You can make your own classes have events by using the eventdispatcher mixin.
http://www.macromedia.com/devnet/mx/flash/articles/creating_events.html
Yes, but it is a custom (not intrinsic or native) class, and then I wonder how do they control the "on(...)" naming convention and how can I add my own events to it. Without using the EventDispatcher, because it, in its turn, is using some native Flash Player functionality...
sleekdigital
07-15-2005, 01:33 PM
Yes, but it is a custom (not intrinsic or native) class
Well, the article is telling you how to do events in custom classes. So what's the problem?
then I wonder how do they control the "on(...)" naming convention
hmmm, your first post was a bit confusing ... first you were talking about "onRelease, onReleaseOutside, onPress" The fact that they all begin with "on" is just becasue that is what they chose to name those events. There is no "control" of the naming convention. If you are asking how they make the movieclip scripts like on(Load) work, I do not know, I do not put scripts on movieclips anymore, so I just don't care about that. To me AS 2 means code goes in classes, not on Movie Clips.
Without using the EventDispatcher, because it, in its turn, is using some native Flash Player functionality...
No, it does not use any native flash player functionality, its just a class like any other... you can even look at the source code, just got to your flash install folder and drill down to \en\First Run\Classes\mx\events. And why would that matter if it did use native player functionality, if you want to use events, using eventDispatcher does the job. Anoother option is to use BroadcasterMX You can find that at \en\First Run\Classes\mx\transitions
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.