The listeners are simply objects that you attach functions to. These listeners are then attached to DynObjects. By saying "attached", they are actually just appended to an internal array used to track the active listeners for a particular DynObject.
During various processes, a DynObject will throw up an event to be handled. At this point, the event is sent to a function that simple step through each attached listener in the array and tests to see if they have an 'onXXXX' method. If found, the method is executed and parsed an 'e' object to tell it the particulars. The use of 'getTarget' is a bit skewed in you example. The value of traget is actually defined in the EventListener. It is set to what even DynObject you parse it on creation. Therefore, in your 'fileb' code, the EventListeners' 'e.getTarget' value will be set to the result of your 'myObject' call. To get the object that originally threw the event, you will need to use the 'getSource' method. As for the 'create' event being out of sync, this is related to the GUI components' creation. It was designed to allow for code that was needed to set values AFTER the browser element was created. This was useful for some widgets that woudln't need to create some elements until they were actually going to be used. hope this all makes sense. ---- Michael Pemberton [EMAIL PROTECTED] ICQ: 12107010 -- Original Message -- From: James Musick <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Send: 2002-07-12 Subject: Re: [Dynapi-Help] what does is the 'e' in function(e) >So, how far off am I to what you wanted to know? Close, especially considering that I didn't do a very good job of clearly expressing my question(s)...probably because of some confusion. I think the problem is that I didn't/don't understand when things are being called and/or triggered by DynAPI. For example: File A: anObj= new myObject(); ....other stuff DynAPI.document.addChild(anObj); --------- File B: function myObject() { this.field1=null;this.field2=null; var l = new EventListener(this); l.oncreate = function(e) {var o = e.getTarget();} } I understand most of what was answered in previous emails (that EventListener is creating an EventListener and assigning it to 'l', and that the anonymous function is being assigned to the .oncreate property of l) What was confusing, I think, to me was *when* oncreate was being called (and by whom). When File A created an instance of a myObject I assumed that oncreate was being called. I now realize that was incorrect. It looks like (based on a liberal sprinkling of debugging statements) oncreate is being called somewhere inside the addChild(anObj) execution. So the way I'm currently thinking of it (and this may *still* be confused...so please correct me/add to the info if possible) is that the above code will 1. Create an instance of myObject called anObj. 2. Part of this object is an EventListener 3. somehow/somewhere the oncreate() function of the event listener is called inside of DynAPI.document.addChild() 4. That call of oncreate is passing a reference of the event 'e' that triggered the 'oncreate' call. 5. e.getTarget() returns the object that triggered it all in the beginning. 3,4,5 are still pretty speculative since I didn't see code doing that specifically. But the addChild() must be triggering the oncreate event somehow, but I'm not sure how/why. You could have multiple Event listeners with a single object, certainly. If you did an addChild() I guess it seems that an event is firing (perhaps of a type that is a creation event) and so all the EventListeners that are associated with the object (only 'l' in this case) execute their oncreate function. I think what was confusing me was that when you create an instance of the object you're not really triggering the oncreate() function. That seems to happen when you do Dynapi.document.addChild(). Is this roughly correct? Thanks, by the way, for the discussion/help. Cheers, James ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek PC Mods, Computing goodies, cases & more http://thinkgeek.com/sf _______________________________________________ Dynapi-Help mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dynapi-help