About invalidation
Macromedia recommends that a component not update itself immediately in most cases, but that
it instead should save a copy of the new property value, set a flag indicating what is changed, and
call the
invalidate()
changed, but size and position of subobjects have not changed. This method calls the
method.)
You must call an invalidation method at least once during the instantiation of your component.
The most common place for you to do this is in the
methods.
Dispatching events
If you want your component to broadcast events other than the events it may inherit from a
parent class, you must call the
The
dispatchEvent()
by all components that extend UIObject. (See
You should also add an Event metadata tag at the top of the class file for each new event. For more
information, see
Note: For information about handling component events in a Flash application, see
"Handling Component Events," on page
Using the dispatchEvent() method
In the body of your component's ActionScript class file, you broadcast events using the
dispatchEvent()
dispatchEvent(eventObj)
The
parameter is an ActionScript object that describes the event (see the example later
eventObj
in this section).
You must declare the
private var dispatchEvent:Function;
You must also create an event object to pass to
information about the event that the listener can use to handler the event.
You can explicitly build an event object before dispatching the event, as the following
example shows:
var eventObj = new Object();
eventObj.type = "myEvent";
eventObj.target = this;
dispatchEvent(eventObj);
You can also use a shortcut syntax that sets the value of the
property and dispatches the event in a single line:
ancestorSlide.dispatchEvent({type:"revealChild", target:this});
In the preceding example, setting the
948
Chapter 7: Creating Components
method. (This method indicates that just the visuals for the object have
dispatchEvent()
method is defined in the mx.events.EventDispatcher class and is inherited
"About the Event tag" on page
method. The
dispatchEvent()
function in your code before you call it, as follows:
dispatchEvent
target
createChildren()
method in the component's class file.
"EventDispatcher class" on page
939.
55.
method has the following syntax:
dispatchEvent()
type
property is optional, because it is implicit.
draw()
or
layoutChildren()
415.)
Chapter 4,
. The event object contains
property and the
target
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?
Questions and answers