Download presentation
Presentation is loading. Please wait.
1
B.Sc. Multimedia ComputingMultimedia Authoring Introduction to ActionScript
2
Agenda Why learn ActionScript ? New features in ActionScript 2.0 ActionScript elements Actions Panel and Editor Planning your script-driven project Testing and debugging scripts B.Sc. Multimedia ComputingMultimedia Authoring
3
Why Learn ActionScript ? More control over movie clips and their properties Animate elements independently of the timeline Import and export data dynamically Dynamic control of sound and video Create objects that have physics-driven behaviors Personalize the user’s experience B.Sc. Multimedia ComputingMultimedia Authoring
4
ActionScript 2.0 Features Strict data typing aVariable = 5; // no type given, compiler has to work it out aVariable:Number = 5 // declare as being a number type Case sensitive myValue not the same as myvalue Class structures for custom objects B.Sc. Multimedia ComputingMultimedia Authoring
5
Elements Keywords Operators Assignment Class Definition Class Method Definition Class Instantiation Class Referencing B.Sc. Multimedia ComputingMultimedia Authoring
6
Structure and Syntax Semicolons Curly Braces Code Blocks Dot Syntax Parenthesis Script Spacing and Layout Comments B.Sc. Multimedia ComputingMultimedia Authoring
7
Comments // this is a comment on one line /* these are comments spanning more than one line */ /* a script to calculate the area of a circle */ var area : Number; // holds the value of the area var PI : Number = 3.142: // sets the value of PI var radius :Number = 5 ; // sets the value of PI area = PI * radius * radius // calculates the area and assigns it to the variable B.Sc. Multimedia ComputingMultimedia Authoring
8
Semicolons ; and Braces {} Semicolons separate statements Curly braces define code blocks B.Sc. Multimedia ComputingMultimedia Authoring
9
Operators Binary + - * / Logical AND && (5 1) is False Logical OR || (5 1) is True Equalty, = Assignment a = 5 B.Sc. Multimedia ComputingMultimedia Authoring
10
Equality == a = ‘5’ x = 5 if (a == x) is True a = 5 x = ‘6’ if (a == x) is False B.Sc. Multimedia ComputingMultimedia Authoring
11
Strict Equality === a = ‘5’ x = 5 Strict equality compares types === if ( a === x) is False a = 5 x = 5 if (a === x) is True B.Sc. Multimedia ComputingMultimedia Authoring
12
Branching - IF Statement if(condition) { statement(s); } if(name == "Erica"){ play(); } B.Sc. Multimedia ComputingMultimedia Authoring
13
Branching - switch var listernerObj:Obj = new Object(); { switch (String,fromCharCode(Key.getAscii())){ case “A” : // do something here Break; case “B : // do something here break: default; B.Sc. Multimedia ComputingMultimedia Authoring
14
Looping: while index = 4; while (index > 0){ // do something here index = index -1; // shorthand index -- } B.Sc. Multimedia ComputingMultimedia Authoring
15
Looping: do while index = 4; do { // do something here index = index -1; // shorthand index -- } while (index > 0); B.Sc. Multimedia ComputingMultimedia Authoring
16
Class Definition class Person { var name:String; var age :Number; } B.Sc. Multimedia ComputingMultimedia Authoring
17
Class Constructor function Person (name:String, age:Number) { this.name = name; this.age = age; } B.Sc. Multimedia ComputingMultimedia Authoring
18
Method Definition function getPersonDetails () :String { return(“Name: “ + this.name + ” Age: “ + this.age); } B.Sc. Multimedia ComputingMultimedia Authoring
19
Class Instantiation and References var newPerson: = new Person(“Jo Smith”, 23); Classes must be saved into external actionscript files e.g. myclass.as and in the same folder as the flash movie that uses the classes B.Sc. Multimedia ComputingMultimedia Authoring
20
ActionScript Editor Actions Toolbox Script Navigator Script Pane
21
References Flash MX 2004 actionscript training from the source Franklin D. Makar J. Macromedia Press 2004 B.Sc. Multimedia ComputingMultimedia Authoring
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.