![adobe flash actionscript 3.0 parts of code adobe flash actionscript 3.0 parts of code](https://i.ytimg.com/vi/fyWi-LjwhFw/maxresdefault.jpg)
- #Adobe flash actionscript 3.0 parts of code how to
- #Adobe flash actionscript 3.0 parts of code movie
- #Adobe flash actionscript 3.0 parts of code code
Once the event is announced, the event listener function will then run, enabling the Flash movie to make the appropriate response.įLASH ACTIONSCRIPT 3 EVENT HANDLING SYNTAX Once an event listener function is registered with an event source, you can think of it as the event listener function sitting there quietly, just waiting to be told or "listening" for when the event is dispatched or announced. This is essentially what connects the event listener function to the event. The addEventListener() method registers the event listener function with the event source so that the event listener function can "hear" when the event is announced. This event source can also be alternatively referred to as the event target.Īfter identifying these 3 elements, you bring them all together using the addEventListener() method. In this case, the URLLoader is the one responsible for loading the external text file and is therefore considered as the event source. For instance, when a URLLoader finishes loading the file, this is considered as an event as well. Another example would be when a URLLoader object loads an external text file. For example, when dealing with mouse click events, the button that was clicked would be the object that the mouse click happens to, and is therefore considered as the event source. In most cases, it is the object from which the event originates from. } REMINDER: The terms event listener, event listener function and listener function all refer to the same thing - it is a function that is registered to execute when a specific event occurs.Īn event source refers to the object that is directly related to the event. response to make when the event happens This function, referred to as an event listener (also sometimes referred to as an event listener function or listener function), will be called immediately after the specified event is dispatched and detected.
#Adobe flash actionscript 3.0 parts of code code
This function's body will contain the line(s) of code that will tell Flash what to do. For example, after a button is clicked ( MouseEvent.CLICK), we can instruct the Flash movie to respond by playing an audio file. And if you were to specify a mouse roll over event, then you would write: MouseEvent.ROLL_OVER.Ī response refers to what is going to happen once Flash detects the occurrence of an event.
![adobe flash actionscript 3.0 parts of code adobe flash actionscript 3.0 parts of code](https://image.slidesharecdn.com/actionscripttutorial-090829090825-phpapp01/95/coding-flash-actionscript30-tutorial-1-728.jpg)
So for example, if you were to specify a mouse click event then you would write: MouseEvent.CLICK. Once these elements have been identified, writing the event in code takes on this form: For a mouse roll over, it is written as ROLL_OVER. The constant for a mouse click is written as CLICK. Let's consider the MouseEvent class, a few of the events that fall under this class are: mouse clicks and mouse roll overs (i.e. There's also another class for mouse events, which is written as MouseEvent.Įvent constants are specific names that refer to the events themselves. when the user presses a keyboard key) and key up (i.e. Some events that fall under this class are the key down (i.e. Another example is the keyboard event class, which is written as KeyboardEvent. Some events that fall under this class are the complete, deactivate, and open events. There's an event class, which is also called Event. In ActionScript 3 event handling, events are identified by specifying the event class as well as the event constant.Įvent classes can be thought of as the different groups used to classify different kinds of events. And then after that, let's take a look at what the event source is.Īn event refers to a specific occurrence that happens as your Flash movie runs. We've already introduced the concepts of events and responses in the first part of this lesson, but let's go ahead and take a look at them again with a little more detail. These are: (1) the event, (2) the response, and (3) the event source.
#Adobe flash actionscript 3.0 parts of code how to
In this next part of the Flash AS3 Event Handling tutorial series, we're going take a look at how to write event handling code.Īccording to the Adobe Flash ActionScript 3 documentation, there are 3 important elements that need to be identified when working with event handling in Flash. Part 2: How to create an AS3 event listener Part 1: Introduction to AS3 event handling