comp126a - university of waikatomhall/126/lecture5_handouts.pdf3 event handlers an event handler is...
TRANSCRIPT
![Page 1: COMP126A - University of Waikatomhall/126/Lecture5_handouts.pdf3 Event Handlers An event handler is some ActionScript instructions to provide a response to an event. In a button](https://reader033.vdocuments.net/reader033/viewer/2022042110/5e8ad80075e73422cb64bac6/html5/thumbnails/1.jpg)
1
COMP126A
Lecture 5: Action ScriptEvents and Properties
Items
Progress with labs Should have finished assignment 1 Hand out Practical 7 and 8
Action Script Events and Properties
![Page 2: COMP126A - University of Waikatomhall/126/Lecture5_handouts.pdf3 Event Handlers An event handler is some ActionScript instructions to provide a response to an event. In a button](https://reader033.vdocuments.net/reader033/viewer/2022042110/5e8ad80075e73422cb64bac6/html5/thumbnails/2.jpg)
2
Demonstrations
http://home.scarlet.be/~bbonte/bonteroom.html
Events
Event: Whenever something happens. Eg: User presses a mouse button press, release, releaseOutside, rollOver, ...
Many events occur. A detailed response toeach provides the richness of moderncomputer interfaces (and excellent Flashweb pages)
![Page 3: COMP126A - University of Waikatomhall/126/Lecture5_handouts.pdf3 Event Handlers An event handler is some ActionScript instructions to provide a response to an event. In a button](https://reader033.vdocuments.net/reader033/viewer/2022042110/5e8ad80075e73422cb64bac6/html5/thumbnails/3.jpg)
3
Event Handlers
An event handler is some ActionScriptinstructions to provide a response to anevent.
In a button on (release) { . . . . . . . }
A movie clip can also respond to events onClipEvent (mouseUp) { . . . . . . . . }
Commands
Setting properties Built-in properties all start with the “_” character property = expression ;
_x = _x + 5 ;
_xscale = 200.0 ;
Symbols (movie clips) have properties See lab handout for a list of interesting ones
![Page 4: COMP126A - University of Waikatomhall/126/Lecture5_handouts.pdf3 Event Handlers An event handler is some ActionScript instructions to provide a response to an event. In a button](https://reader033.vdocuments.net/reader033/viewer/2022042110/5e8ad80075e73422cb64bac6/html5/thumbnails/4.jpg)
4
Getting at properties
In a movie clip event handler we just usethe property name to refer to a property ofthat clip instance: _x
We can also use: this._x ‘this’ means the current movie clip, or
whatever we are coding in at the time The style symbol._x is always a way of
getting at a property
Getting at properties
Symbols can be given ‘instance’ names With instance name ‘StarOne’
we can write StarOne._x The special name _root means the
timeline for our current movie. Objects onthe stage are owned by the timeline
We can write _root.StarOne._x
![Page 5: COMP126A - University of Waikatomhall/126/Lecture5_handouts.pdf3 Event Handlers An event handler is some ActionScript instructions to provide a response to an event. In a button](https://reader033.vdocuments.net/reader033/viewer/2022042110/5e8ad80075e73422cb64bac6/html5/thumbnails/5.jpg)
5
Adding Properties to Instances
We can add our own properties (variables)to named instances Eg. StarOne.direction = 1; For example, could be used to record the initial
state of a clip this.startx = this._x;