Variables, Debugging, Control Structures - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Variables, Debugging, Control Structures

Description:

'I'm sad' Utah State. Variable Types. null. All other classes, including user-defined classes. ... if(face.currentFrame = 3) { faceState.text = 'I'm sad. ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 16
Provided by: aew2
Category:

less

Transcript and Presenter's Notes

Title: Variables, Debugging, Control Structures


1
Variables, Debugging, Control Structures
2
Topics
  • Using variables
  • Debugging
  • Control structures (if statements)
  • The currentFrame property
  • Library folders

3
Variables/Properties
  • Placeholders for information
  • Name
  • Value
  • Type
  • Flash Card analogy.
  • Flash syntax
  • var variableNametype value

4
Flash Card Analogy
faceState.text
Im happy
Im sad
5
Variable Types
Adapted from CS3 help file
6
Using Variables
  • When to use
  • Awaiting user input/tracking information
  • You are using values for the same thing in
    multiple places (kind of a constant).
  • MLK project (example)

7
If statements
  • A kind of control structure (conditions/loops)
  • Something we use every day
  • Flash syntax
  • if(condition)
  • // this will run if condition is true.

8
(No Transcript)
9
Examples
  • if(face.currentFrame lt 3)
  • faceState.text Im sad.
  • / borrowed with permission from Alan Wayman,
    2007based on an .fla file he adapted and sent
    via email. /

10
Can be extended (nesting)
  • rachelSwimLessons false
  • if (rachelMood brave)
  • if (weather ! thunder and lightning)
  • if (pool open)
  • rachelSwimLessons true

11
Logical operators
  • rachelSwimLessons false
  • if (rachelMood brave weather ! thunder
    and lightning pool open)
  • rachelSwimLessons true

12
Using else if and else
  • if(face.currentFrame lt 4)
  • faceState.text Im sad.
  • else if (face.currentFrame gt 8)
  • faceState.text Im happy.
  • else
  • faceState.text Im ok.
  • / borrowed with permission from Alan Wayman,
    2007based on an .fla file he adapted and sent
    via email. /

13
Commenting code
  • Two options
  • // Best for one line comments
  • / If you want to have more than one line, then
    you can use this style
  • for as
  • many lines
  • as
  • you
  • need /

14
Debugging
  • Control-gtDebug Movie
  • Lets you watch variable values (and properties)
  • Two kinds of errors
  • Logic
  • Syntax
  • Other option trace()

15
Dont forget
  • Library folders
  • Layer folders
Write a Comment
User Comments (0)
About PowerShow.com