ActionScript codes for common mouse events.
(use these codes when you create ou listener)
*MouseEvent.CLICK
*MouseEvent.MOUSE_MOVE
*MouseEvent.MOUSE_DOWN
*MouseEvent.MOUSE_UP
*MouseEvent.MOUSE_OVER
*MouseEvent.MOUSE_OUT
Adobe Flash animation; Dreamweaver website authoring; Photoshop imaging and graphics design; Wordpress blogging and content management system; Web Development
Sunday, November 7, 2010
Flash - ActionScript - adding the event listener and function
Add ActionScript code to listen for a mouse click on each button.
The response will make Flash fo to a particular frame on the Timeline to show different content.
(the above is referring specifically to the hand-on follow-along example on chapter 6 of "classroom in a book)
The response will make Flash fo to a particular frame on the Timeline to show different content.
(the above is referring specifically to the hand-on follow-along example on chapter 6 of "classroom in a book)
Flash - ActionScript - Event Handling - Create a Listener - Create and Specify a Function
The first step in event handling is to create a listener that will detect the event.
A listener looks something like this:
wheretolisten.addEventListener(whatevent, responsetoevent);
The actual command is addEventListener().
wheretolisten is the object where the event occurs (usually a button). [e.g. "btn1" (a button that you named btn1)]
whatevent is the specific kind of event (such as a mouse click). [e.g. "MouseEvent.CLICK" ]
respondtoevent is the name of a function that is triggered when the event happens. [e.g. "showimage1" (a function that you naemed showimage1)]
The next step is to create a function that will respond to the event.
A function is simple a group of actions that are bunched together. You can trigger a function be referencing its name.
A function looks something like this:
function showimage1 (myEvent: MouseEvent) {};
In the above example, the function receives one parameter (within the parentheses) called myEvent, which is an event that involes the mouse. The item following the colon indicates what type of object it is. If the function is triggered, all the actions between the curly brackets are executed.
**reference: "Adobe cs5 Flash Classroom in a Book"
A listener looks something like this:
wheretolisten.addEventListener(whatevent, responsetoevent);
The actual command is addEventListener().
wheretolisten is the object where the event occurs (usually a button). [e.g. "btn1" (a button that you named btn1)]
whatevent is the specific kind of event (such as a mouse click). [e.g. "MouseEvent.CLICK" ]
respondtoevent is the name of a function that is triggered when the event happens. [e.g. "showimage1" (a function that you naemed showimage1)]
The next step is to create a function that will respond to the event.
A function is simple a group of actions that are bunched together. You can trigger a function be referencing its name.
A function looks something like this:
function showimage1 (myEvent: MouseEvent) {};
In the above example, the function receives one parameter (within the parentheses) called myEvent, which is an event that involes the mouse. The item following the colon indicates what type of object it is. If the function is triggered, all the actions between the curly brackets are executed.
**reference: "Adobe cs5 Flash Classroom in a Book"
Flash - ActionScript - Events / Event Listeners / Event Handlers
Some events are created by the user, for example a mouse click, a mouse movement, or a key press on the keyboard. Other events can happen inpedendent of the user, for example the successful loading of a piece of data, or the completion of a sound.
With Action Script you can write code that detects events and respond to them with an event handler.
*reference: "Adobe cs5 Flash Classroom in a Book"
With Action Script you can write code that detects events and respond to them with an event handler.
*reference: "Adobe cs5 Flash Classroom in a Book"
Flash - ActionScript - Script Navigator
At the bottpm left of the Actions panel is the Script Navigator. The Script navigator can help you find a particular piece of code.
ActionScript is placed on keyframes on the Timeline, so the Script navigator can be particularly useful if you have lots of code scattered in different keyframes and on different Timelines.
**excerpted from "Flash CS5 Classroom in a Book"
ActionScript is placed on keyframes on the Timeline, so the Script navigator can be particularly useful if you have lots of code scattered in different keyframes and on different Timelines.
**excerpted from "Flash CS5 Classroom in a Book"
Flash - ActionScript - the Actions Panel
The Actions Panel is where you write all your code.
Ways to open the actions panel:
1. Windows -> Actions
2. select a keyframe on the timeline and click the "ActionScript icon" on the top right of the Properties inspector.
3. right-click/ctrl-click on any keyframe and select Actions.
4. select keyframe on the timeline and press "F9"
Ways to open the actions panel:
1. Windows -> Actions
2. select a keyframe on the timeline and click the "ActionScript icon" on the top right of the Properties inspector.
3. right-click/ctrl-click on any keyframe and select Actions.
4. select keyframe on the timeline and press "F9"
Subscribe to:
Posts (Atom)