It's possible you are getting confused in further details about event
handling. There is some invisible stuff happening here that goes
beyond just understanding classes and objects. Buttons and MovieClips
are registered listeners of mouse events automatically. What this
means is that an event broadcaster will call specific methods of any
button or movie clip. By default, however, these methods do not exist
-- that is, there are no such properties as onMouseMove, onRelease,
etc.

In a class, you would define methods (normally) in the class definition:

class MyThing {
 function onRelease() {
   doSomething();
 }
}

However with buttons and clips you often are dealing with an object
(aka instance), rather than the class, so you can take advantage of
ActionScript's allowing dynamic properties. This feature means you can
add new methods and properties to object instances that were not
defined in the class:

var obj:Object = new Object();
obj.new_prop = "foo";
obj.doSomething = function () { trace "something"; }

And so, with a button or clip, you can assign an event handler:

my_mc.onRelease = function() {
 // respond to mouse click
}

Once this method exists in the object, it will respond to this event,
which it has previously been receiving and ignoring.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to