Week 10: Advanced Events

Topics:

  • Advanced Events
    • Timers
    • Enter Frame
    • Drag and Drop
  • Final Project Requirements
  • Planning Your Project

Advanced Events

Enter Frame

The enter frame event is triggered every time that the movie enters a frame:

//create the enter frame event
addEventListener(Event.ENTER_FRAME,onEnterFrame;

function onEnterFrame(evt:Event) {
//do something
}

This comes in handy when you want to use code to move an object across the stage!

Timers

You can also trigger an event based on an interval of time passing, with a Timer event:

//create the new timer and set the delay and the number of repetitions
var myTimer:Timer = new Timer(1000, 5);

//add the event listeners to handle the timer events when it is detected
myTimer.addEventListener(TimerEvent.TIMER, onTimer);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);

//start the timer
myTimer.start();

//run this function when the TIMER event fires
function onTimer(evt:TimerEvent) {
//do something
trace("Ding!");
}

//run this function when the timer COMPLETE event fires
function onTimerComplete(evt:TimerEvent) {
//do something
trace("All done");
}

Drag and Drop Events

Any named movieclip instance on the stage can be made “draggable” with the startDrag( ) method.

myObject.startDrag();

Usually this is triggered with an event listener on the MOUSE_DOWN event on the instance. Once startDrag is called, the object will follow the mouse movement. To stop this behavior, you use the stopDrag( ) method, usually implemented on MOUSE_UP.

myObject.stopDrag();

This behavior also has a property associated called dropTarget. The dropTarget is the object that is under the draggable object when the stopDrag method is called. To get the name of the drop target, you must access its name property.

myObject.dropTarget.name;

Final Project

Your final project will take the form of an “Interactive Documentary.” The choice of topic is yours, I suggest something that you are already an expert in or passionate fan of. Your documentary can be instructional (like a ‘how-to’) or informational.

Final Project Requirements

Depending on the focus and execution of your project, it may include more or less of the following components, but must include some of all:

  • Timeline animation
  • Code control of timeline playback
  • Buttons that respond to mouse input
  • Dynamic Text fields and Input Text Fields (we’ll learn these next week)

Optionally, you can also incorporate the following:

  • Audio (we’re going to learn more audio methods next week)
  • Drag and Drop Events
  • Animating with Code (Enter Frame Events)
  • Timer Events

Planning your project

For next week you are going to produce two documents that will help you define your project.

1. Project Brief – This is a text description of your project. It should include the following:

  • Overview: A few sentence summary of the project.
  • Audience: Who is application for? Include age range, gender, anticipated technical skills, language capability.
  • Platform: How do you envision this application being used? Is it part of a larger Web site? A mobile application? Part of an installation?
  • Functionality requirements: Describe how the application will operate. How many distinct states or screens or pages will it have? How will a user interact with it?
  • Technical requirements: Describe as best you can what code elements will be required for the application.

 2. Process Flow – This is a bit like a site map for a Web site. A process flow visualizes the way a user would move through the application from a high level.

Every distinct state or page of the application should be represented by a rectangle, connected by diamond shaped decision points.

This entry was posted in Lessons. Bookmark the permalink.

Leave a Reply