Programming scripting

420 views

Published on

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

Programming scripting

  1. 1. PROGRAMMING SCRIPTING<br />Action Script 2.0<br />
  2. 2. ACTION SCRIPT 2.0<br />Merupakan bahasa pengaturcaraan berasaskan objek (objek oriented programming)<br />Ianya boleh dibina/dibentuk sendiri selain menggunakan Action Sript yang sedia ada<br />Ia digunakan kepada ‘objek’ iaitu:<br /><ul><li>Movie
  3. 3. Grafik
  4. 4. Button </li></li></ul><li>ANIMASI<br />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.<br />
  5. 5. 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.<br />
  6. 6. Mengapa Perlu Belajar ActionScript?<br />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. <br />
  7. 7. Bagaimana Menulis ActionScript?<br />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.<br />
  8. 8. ActionScript berasaskan masaialah apabila arahan actionscript dimasukkan pada frame. Action yang diarahkan akan dimainkan apabila playhead sampai pada frame yang mengandungi action.<br />ActionScript berasaskan penggunaberlaku apabila butang action mengandungi arahan actionscript . Action yang diarahkan pada butang dimainkan apabila pengguna memberi input, biasanya dalam bentuk mouse event<br />
  9. 9.
  10. 10. Action Toolboxmengandungi action atau script yang telah sedia ada dalam Flash<br />Script Pane memaparkan turutan action yang dimasukkan <br />Script Navigatormemaparkan semua script dalam movie pada scene & timeline<br /><ul><li> Selain daripada di Action Toolbox, anda juga boleh memilih action yang diperlukan dengan menekan butang Add Statement</li></li></ul><li>10<br />Actions<br />Tell Flash to do something<br />Frame actions <br />Object actions<br />Actions also can have parameters<br />
  11. 11. 11<br />gotoAndPlay<br />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. <br />
  12. 12. 12<br />Functions<br />Perform a specific task<br />Like in a spreadsheet program (Excel)<br />
  13. 13. 13<br />getVersion<br />Returns the Flash Player version number and operating system information. <br />You can use this function to determine whether the Flash Player that is in use can handle your Actionscript.<br />
  14. 14. 14<br />Properties<br />All available information about an object<br />You can use ActionScript to read and modify object properties<br />All property names begin with an underscore (e.g., _visible)<br />
  15. 15. 15<br />_visible = false<br />This property make an object invisible<br />Assign the following action to a button…<br />On (release) {<br /> _visible = false;<br />}<br />Button disappears on mouse click<br />
  16. 16. 16<br />Method<br />Similar to actions in that they effect objects<br />Built into objects <br />Invoked (Executed) through dot notation<br />
  17. 17. 17<br />RocketMC.gotoAndPlay(“BlastOff”);<br />ActionScript notation must end in ;<br />Movie clip Rocket MC goes to a frame labeled BlastOff and plays<br />
  18. 18. 18<br />Variables<br />hold data for use in your Flash movies<br />Variables can hold any type of data<br />You could store:<br />User name<br />Result of calculation<br />True or false value<br />
  19. 19. 19<br />Expressions<br />An expression is any statement that Flash can evaluate and that returns a value. <br />You can create an expression by combining operators and values or by calling a function. <br />
  20. 20. 20<br />Operators<br />Expressions use operators to tell Flash how to manipulate the values in the expression.<br />They are the commands that say “add these values” or “multiply these numbers”<br />
  21. 21. 21<br />Some types of operators<br />Assignment: <br />are used to assign values to variables. <br />The most common is (=). It makes the variable on the left equal to the value of the variable or expression on the right.<br />Comparison and equivalence: <br />(<), (>), (< =)<br />Numeric: <br />perform mathematical operations on values<br />
  22. 22. 22<br />Looping<br />When you need to repeat certain actions in your movies more than once.<br />Makes coding more efficient, using the same set of commands as many times as necessary to complete a task.<br />
  23. 23. 23<br />Looping examples<br />while<br />Creates a loop that continues to repeat as long as a condition remains true<br />for<br />Creates a loop that executes a specific number of times using a counter<br />for…in<br />Creates a loop that executes once for each member of a group of objects (class)<br />This makes certain that the entire group of objects is processed in the same way<br />
  24. 24. 24<br />Hints<br />Before you begin writing scripts, formulate your goal and understand what you want to achieve. <br />Planning your scripts is as important as developing storyboards for your work. <br />Start by writing out what you want to happen in the movie, as in this example: <br />I want to create my whole site using Flash. <br />Site visitors will be asked for their name, which will be reused in messages throughout the site. <br />The site will have a draggable navigation bar with buttons that link to each section of the site. <br />When a navigation button is clicked, the new section will fade in at the center of the Stage. <br />One scene will have a contact form with the user's name already filled in.<br />

×