1 / 36

Chapter 9 Interactive Multimedia Authoring with Flash

Chapter 9 Interactive Multimedia Authoring with Flash. Introduction to Programming. Some Common Terms. Writing code means entering the code is part of the process of creating the computer program Running code, executing code

kyria
Download Presentation

Chapter 9 Interactive Multimedia Authoring with Flash

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 9Interactive Multimedia Authoring with Flash Introduction to Programming

  2. Some Common Terms • Writing code • means entering the code • is part of the process of creating the computer program • Running code, executing code • refers to the process by which the computer carries out the instructions in a computer program • Compiling • refers to the process of assembling code into a format suitable for the computer to execute the instructions

  3. More Common Terms • Computer Programming Languages • are for writing instructions that can be followed by a computer • IDE • stands for:Integrated Development Environment • refers to: • the software in which you are developing an application • for example, Adobe Flash, Microsoft Visual Studio

  4. Programming Languages Multimedia authoring scripting languages, such as Flash Actionscript and Director Lingo are often the highest level. high level Programming languages that look more like human language. Easy for human to read and write, but require more "translation" behind the scenes to be understandable to the computer. e.g. C++, Java, FORTRAN Assembly language low level lowest level: Machine language: a programming language that communicates with a computer through 0's and 1's

  5. Scripting Languages • Examples: Flash ActionScript, Director Lingo, Javascript • Very-high-level programming languages • Advantage: easier for non-programmer to learn because the syntax and keywords are close to human languages • Disadvantages: • Not as full-fledged as programming languages such as C++, Java, and FORTRAN • Don't have the features to let the programmer to control low level details, such as memory allocation

  6. The newest version of ActionScript. More difficult than the other two versions. This is what we will be using in this course. Easiest to learn. Has stricter rules than 1.0. Flash Actionscript • a scripting language • getting full-fledged • based on the same standard as Javascript • Actionscript 1.0, 2.0, 3.0

  7. Syntax • prescribes the ways in which statements must be written in order for them to be understood by the computer • like the rules of grammar and punctuation in human languages, but these rules must be followed precisely in computer programming • for examples, for ActionScript: • case sensitive • each statement ends with a semi-colon(;) • the naming of variables and functions has to start with a letter , _ or $

  8. Variables • Purpose:to store values that can be updated and retrieved at runtime • Data is stored in memory as bits. • Variable lets you refer, by name, to the data's memory location stored.

  9. Variable Naming • can contain a number, a letter, underscore (_), or dollar sign ($) • cannot begin with a number • in this course, variables always begin with a letter • cannot be a keyword • look up Actionscript 3.0 Language Reference in Help for all the keywords • If the word turns blue in your code window, it means it is a keyword.

  10. Case Sensitivity of Variable Names • score and Score are different • number and nuMBer are different

  11. Assigning a Value to a Variable • Means giving a value to a variable • The statement that assigns a value to a variable is called an assignment statement.

  12. Assigning a Value to a Variable General Syntax: variableName=value or expression; Examples: score = 10; letterGrade = "A"; sum = a + b;

  13. Declaring a Variable • Before you use a variable or assigning a value to a variable, you need to declare the variable. • General Syntax:Two ways to declare a variable: • Declare without assigning a value:varvariableName:dataType; • Declare and assign a value:varvariableName:dataType=value or expression;

  14. Declaring a Variable Examples: var score:int; var score:int = 0;

  15. Data Types Basic Data Types in Actionscript int uint Number String Boolean MovieClip Object Null void

  16. How a Program Runs • A program is written as a sequence of statements as instructions. • The program executes the instructions sequentially--one instruction after the other, in the order in which they appear in the code. • Use control structures to make nonsequential execution of the instructions.

  17. Types of Control Structures • Loop • A set of statements is executed repeatedly until a certain condition is reached • Will be covered in Chapter 11 • Conditional • A set of statements is executed only if some conditions are met • if statements and switch statements

  18. if Statements • if • if...else • if...else if • Nested if statements

  19. if General Syntax: if (logical expression(s)) { statement(s) } The statements grouped within the curly braces are called the block statements.

  20. if Example: if (score > 600) { grade = "pass"; }

  21. if • If there is only one statement to be executed, the curly braces are optional. • Examples: if (score > 60) grade = "pass"; The statement may be on a single line: if (score > 60) grade = "pass";

  22. if...else General Syntax: if (logical expression(s)) { statement(s) } else { statement(s) }

  23. if...else Example: if (score > 60) { grade = "pass"; } else { grade = "fail"; }

  24. if...else if General Syntax: if (logical expression(s)) { statement(s) } else if (logical expression(s)) { statement(s) } ... else if (logical expression(s)) { statement(s) } else { statement(s) }

  25. if...else if Example: if (score > 90) { grade = "A"; } else if (score > 80) { grade = "B"; } else if (score > 70) { grade = "C"; } else if (score > 60) { grade = "D"; } else { grade = "F"; }

  26. if...else if • The conditions are checked one at a time sequentially. • Once a condition is found to be true, the statement(s) for that condition will be executed and the rest of the conditions in the if . . . else if statements group will not be checked.

  27. if...else if Suppose score = 85. Example: if (score > 90) { grade = "A"; } else if (score > 80) { grade = "B"; } else if (score > 70) { grade = "C"; } else if (score > 60) { grade = "D"; } else { grade = "F"; }

  28. if...else if Suppose score = 85. First check: (score > 90). (85 > 90) is false! Example: if (score > 90) { grade = "A"; } else if (score > 80) { grade = "B"; } else if (score > 70) { grade = "C"; } else if (score > 60) { grade = "D"; } else { grade = "F"; }

  29. Logical Operators && AND || OR ! NOT

  30. Logical AND: && logicalExpression1&&logicalExpression2 true : only when bothlogicalExpression1 and logicalExpression2 are true false : when eitherlogicalExpression1 or logicalExpression2 is false

  31. Logical OR: || logicalExpression1||logicalExpression2 true : when eitherlogicalExpression1 or logicalExpression2 is true false : only when bothlogicalExpression1 and logicalExpression2 is false

  32. Logical NOT: ! !logicalExpression1 true : when logicalExpression1 is false false : when logicalExpression1 is true

  33. Examples Example 1 Example 2 if (age < 40 || weight < 150) { group = 2; } else { group = 3; } if (age < 40 && weight < 150) { group = 2; } else { group = 3; } Which statement will be executed in these examples when age = 38 and weight = 145?

  34. Examples Example 1 Example 2 if (age < 40 || weight < 150) { group = 2; } else { group = 3; } if (age < 40 && weight < 150) { group = 2; } else { group = 3; } Which statement will be executed in these examples when age = 38 and weight = 157?

  35. Examples Example 1 Example 2 if (age < 40 || weight < 150) { group = 2; } else { group = 3; } if (age < 40 && weight < 150) { group = 2; } else { group = 3; } Which statement will be executed in these examples when age = 46 and weight = 145?

  36. Examples Example 1 Example 2 if (age < 40 || weight < 150) { group = 2; } else { group = 3; } if (age < 40 && weight < 150) { group = 2; } else { group = 3; } Which statement will be executed in these examples when age = 46 and weight = 157?

More Related