Download - Programming scripting
ACTION SCRIPT 2.0
Merupakan bahasa pengaturcaraan berasaskan objek (objek oriented programming)
Ianya boleh dibina/dibentuk sendiri selain menggunakan Action Sript yang sedia ada
Ia digunakan kepada ‘objek’ iaitu: Movie Grafik Button
ANIMASI
Animasi merujuk kepada proses menghidupkan sesuatu yang statik agar kelihatan dinamik. Macromedia Flash menawarkan pelbagai teknik dan kaedah membina animasi berdasarkan perubahan yang berlaku di antara satu frame dengan frame lain.
Pelbagai jenis animasi dapat dihasilkan dengan pengunaan ActionScript.
Pengunaan ActionScript tidak melibatkan banyak pengunaan grafik.
Apa yang dilakukan di sini ialah memaklumkan tindakan (Action) yang
perlu dilaksanakan bagi sesuatu peristiwa (event) itu berlaku.
ActionScript membenarkan pengguna untuk mereka movie interaktif yang
dimainkan dalam turutan nonlinear dan respon terhadap input pengguna daripada keyboard atau mouse.
MENGAPA PERLU BELAJAR ACTIONSCRIPT?
Selain mengetahui kod disebalik Flash, ActionScript juga berguna di dalam membangunkan aplikasi interaktif tambahan terhadap movie yang dibina atau menggerakkan objek dari satu kedudukan ke kedudukan lain.
BAGAIMANA MENULIS ACTIONSCRIPT?
Menulis ActionScript adalah tidak lain daripada menulis arahan. Setiap arahan yang dimasukkan memaklumkan kepada Flash untuk melakukan sesuatu secara spesifik. Contohnya, “play”, “stop”, “or” dan sebagainya. Dengan menentukan arahan bagi setiap baris ActionScript secara spesifik, membenarkan pengguna mencantumkan dan menghasilkan arahan yang lebih baik. Tetapi harus di ingati bahawa setiap “sentence”( baris kod) merupakan arahan yang tunggal.
ActionScript berasaskan masa ialah apabila arahan actionscript dimasukkan pada frame. Action yang diarahkan akan dimainkan apabila playhead sampai pada frame yang mengandungi action.
ActionScript berasaskan pengguna berlaku apabila butang action mengandungi arahan actionscript . Action yang diarahkan pada butang dimainkan apabila pengguna memberi input, biasanya dalam bentuk mouse event
Tanda Simbol FungsiParentheses ( ) Satu tanda yang menyimpan statement bagi sesuatu arahan
Semikolon ; Tanda yang digunakan pada hujung skrip dalam satu baris yang berfungsi sebagai penutup bagi Actionscript
Curley Braces { } Tanda yang digunakan bagi mengumpulkan skrip yang berkaitan bagi sesuatu proses kerja dalam satu medan Contoh : On(release){gotoAndPlay(“babak1”);}
Dot Syntax . Digunakan bagi menentukan properties bagi sesuatu objek atau movie Contoh :On(press){Bola.play( );}
Kod Warna Pernyataan
Biru Action
Hijau Properties sesuatu objek
Hitam Elemen lain dalam script
Action Toolbox mengandungi action atau script yang telah sedia ada dalam Flash Script Pane memaparkan turutan action yang dimasukkan Script Navigator memaparkan semua script dalam movie pada scene & timeline
• Selain daripada di Action Toolbox, anda juga boleh memilih action yang diperlukan dengan menekan butang Add Statement
11
GOTOANDPLAY
This frame action sends the playhead to the specified frame in a scene and plays from that frame. If no scene is specified, the playhead goes to the specified frame in the current scene.
13
GETVERSION
Returns the Flash Player version number and operating system information.
You can use this function to determine whether the Flash Player that is in use can handle your Actionscript.
14
PROPERTIES
All available information about an object
You can use ActionScript to read and modify object properties
All property names begin with an underscore (e.g., _visible)
15
_VISIBLE = FALSE
This property make an object invisible Assign the following action to a
button…On (release) {
_visible = false;}
Button disappears on mouse click
16
METHOD
Similar to actions in that they effect objects
Built into objects Invoked (Executed) through dot
notation
17
ROCKETMC.GOTOANDPLAY(“BLASTOFF”);
ActionScript notation must end in ; Movie clip Rocket MC goes to a frame
labeled BlastOff and plays
18
VARIABLES
hold data for use in your Flash movies Variables can hold any type of data You could store:
User name Result of calculation True or false value
19
EXPRESSIONS
An expression is any statement that Flash can evaluate and that returns a value.
You can create an expression by combining operators and values or by calling a function.
20
OPERATORS
Expressions use operators to tell Flash how to manipulate the values in the expression.
They are the commands that say “add these values” or “multiply these numbers”
21
SOME TYPES OF OPERATORS
Assignment: are used to assign values to variables. The most common is (=). It makes the
variable on the left equal to the value of the variable or expression on the right.
Comparison and equivalence: (<), (>), (< =)
Numeric: perform mathematical operations on values
22
LOOPING
When you need to repeat certain actions in your movies more than once.
Makes coding more efficient, using the same set of commands as many times as necessary to complete a task.
23
LOOPING EXAMPLES
while Creates a loop that continues to repeat as long
as a condition remains true for
Creates a loop that executes a specific number of times using a counter
for…in Creates a loop that executes once for each
member of a group of objects (class) This makes certain that the entire group of
objects is processed in the same way
24
HINTS
Before you begin writing scripts, formulate your goal and understand what you want to achieve.
Planning your scripts is as important as developing storyboards for your work.
Start by writing out what you want to happen in the movie, as in this example: I want to create my whole site using Flash. Site visitors will be asked for their name, which will be
reused in messages throughout the site. The site will have a draggable navigation bar with buttons
that link to each section of the site. When a navigation button is clicked, the new section will
fade in at the center of the Stage. One scene will have a contact form with the user's name
already filled in.