1.
In the following code sample, what is the underlined part of the code commonly referred to as? (choose one)
contact.addEventListener (MouseEvent.MOUSE_DOWN, mouseDownHandler0);
Correct Answer
A. Target event
Explanation
The underlined part of the code is commonly referred to as the "target event". This is because it specifies the event that the code is listening for, in this case, the "MouseEvent.MOUSE_DOWN" event.
2.
The following code is doing what? (Choose one)
about.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
function mouseDownHandler2(event:MouseEvent):void {
gotoAndStop("about");
}
Correct Answer
B. When a user clicks a button the animation advances to the frame labeled ‘about’
Explanation
The given code is adding an event listener to the "about" button. When the user clicks on the button, the function "mouseDownHandler2" is called. This function uses the "gotoAndStop" method to advance the animation to the frame labeled 'about'. Therefore, when a user clicks the button, the animation advances to the frame labeled 'about'.
3.
Event listeners contain two parameters: the listener parameter and the type parameter. The type parameter specifies the type of event. In the code sample below, what part of the code is the type parameter? (choose one)
function myFunction(e:MouseEvent):void {
}
ep_btn.addEventListener(MouseEvent.MOUSE_OVER, myFunction)
Correct Answer
C. MouseEvent.MOUSE_OVER
Explanation
In the given code, the type parameter is "MouseEvent.MOUSE_OVER". This is because "MouseEvent.MOUSE_OVER" specifies the type of event that the event listener is listening for.
4.
There are two ways to define a function in ActionScript 3.0: you can use a function statement or a function expression. As a general rule, use a function statement. Which statement below best explains why this is true? (Choose one)
Correct Answer
B. Function statements are less verbose, and they provide a more consistent experience between strict mode and standard mode than function expressions.
Explanation
Function statements are less verbose and provide a more consistent experience between strict mode and standard mode than function expressions. Function statements allow for a clearer and more readable code structure, making it easier to understand and maintain. Additionally, function statements can be used in both strict mode and standard mode, ensuring a consistent behavior across different environments. On the other hand, function expressions can be anonymous and may require additional steps to reuse in the code, potentially leading to a less elegant coding style.
5.
Event listeners contain two parameters: the listener parameter and the type parameter. The listener parameter specifies the listener function that will execute when the event occurs. The listener parameter can be a reference to either a function or a class method. In the code sample below, what is the listener parameter? (Choose one)function myFunction(event:MouseEvent):void { }ep_btn.addEventListener(MouseEvent.MOUSE_CLICK, myFunction)
Correct Answer
B. The second instance of myFunction
Explanation
In the given code sample, the listener parameter is referring to the second instance of the function "myFunction". This means that when the event "MouseEvent.MOUSE_CLICK" occurs, the second instance of the function "myFunction" will be executed.
6.
How do you add an object to the Display List? (choose two)
Correct Answer(s)
A. By dragging it onto the stage
C. By importing it to stage
Explanation
The correct answers are "By dragging it onto the stage" and "By importing it to stage". These two methods allow you to add an object to the Display List. By dragging it onto the stage, you can simply click and drag the object from the library or another location onto the stage. By importing it to stage, you can use the import function to bring the object into the stage from an external source or library.
7.
The name of the event is defined by the constant associated with the event class. In the code sample below, choose the constant. (choose one)function functionName(event:MouseEvent):void {}next.addEventListener(MouseEvent.MOUSE_DOWN, functionName)
Correct Answer
D. MOUSE_DOWN
Explanation
In the given code sample, the constant associated with the event class that defines the name of the event is "MOUSE_DOWN". This constant is used in the addEventListener function to specify the type of event that the function "functionName" should listen for.
8.
The piece of code for a typical button action requires which of the following three pieces? (choose three)
Correct Answer(s)
A. Defined Function
C. Instance Name
D. Event Listener
Explanation
The code for a typical button action requires a defined function, an instance name, and an event listener. A defined function is necessary to specify the actions that should be performed when the button is clicked. An instance name is used to identify the specific button that is being clicked. An event listener is needed to detect when the button is clicked and trigger the associated function. Variables and data types may be used within the function, but they are not essential components for the button action code.
9.
An event listener is essentially: (Choose one)
Correct Answer
A. A function
Explanation
An event listener is essentially a function that is responsible for handling an event when it occurs. It is used to specify the behavior that should be executed when a particular event takes place, such as a button click or a key press. The event listener function is attached to a target node, which is the element on which the event is expected to occur. When the event is triggered, the event listener function is called and executed. Therefore, the correct answer is "a function".
10.
The event flow consists of the following three concepts (Choose one):
Correct Answer
D. Capture, target, bubble
Explanation
The correct answer is capture, target, bubble. In event flow, capture phase happens first where the event is captured by the parent elements before reaching the target element. Then, the event reaches the target element in the target phase. Finally, in the bubble phase, the event bubbles up from the target element to its parent elements. This sequence of capture, target, and bubble is the correct order of concepts in event flow.