07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ADOBE DIRECTOR BASICS<br />

Asynchronous programming<br />

Using an actorList event to remove an object<br />

If you click on the lower button, the event #deleteMe is sent to the actorList. The Set Color and Text instance receives<br />

the #deleteMe call first, and uses it to remove itself from the actorList. There are now only two objects remaining on<br />

the actorList, but <strong>Director</strong> considers that it has already sent the #deleteMe call to the first item on the list. For this<br />

reason, the event is never sent to the Rotate Text behavior. Instead, it is sent immediately to the second item on the list;<br />

the Just Delete Me script deletes itself from the actorList, but the text sprite continues to rotate.<br />

The same effect will occur if you use a #stepFrame event to remove an object from the actorList. If there is only one<br />

object on the actorList, or if it is not a problem if the next object misses a #stepFrame event, then you do not need to<br />

do anything special. If you want to be sure that all objects on the actorList receive a #stepFrame event in all<br />

circumstances, then you can use the handler below:<br />

on RemoveFromActorList(aInstance)<br />

vIndex = (the actorList).getPos(aInstance)<br />

if not vIndex then<br />

exit<br />

end if<br />

(the actorList).deleteAt(vIndex)<br />

if vIndex

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!