Utah State Variables, Debugging, Control Structures.
-
date post
21-Dec-2015 -
Category
Documents
-
view
230 -
download
2
Transcript of Utah State Variables, Debugging, Control Structures.
![Page 1: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/1.jpg)
Utah State
Variables, Debugging, Control Structures
![Page 2: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/2.jpg)
Utah State
Topics
Using variables Debugging Control structures (if statements) The currentFrame property Library folders
![Page 3: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/3.jpg)
Utah State
Variables/Properties
Placeholders for information Name Value Type Flash Card analogy.
Flash syntax:var variableName:type = value;
![Page 4: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/4.jpg)
Utah State
Flash Card Analogy
faceState.text “I’m happy”
“I’m sad”
![Page 5: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/5.jpg)
Utah State
Variable Types
Data type Default value
Boolean false
int 0
Number NaN
Object null
String null
uint 0
Not declared (equivalent to type annotation *) undefined
All other classes, including user-defined classes. null
Ad
apted
from C
S3 h
elp
file
![Page 6: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/6.jpg)
Utah State
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)
![Page 7: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/7.jpg)
Utah State
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.
}
![Page 8: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/8.jpg)
Utah State
Comparison
< Less than
> Greater than
<= Less than or equal
>= Greater than or equal
Logical
&& Logical AND
|| Logical OR
! Logical NOT
Equality
== Equality
=== Strict equality
!= Inequality
!== Strict inequality
![Page 9: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/9.jpg)
Utah State
Examples
if(face.currentFrame <= 3) {
faceState.text = “I’m sad.”;
}
/* borrowed with permission from Alan Wayman, 2007—based on an .fla file he adapted and sent via email. */
![Page 10: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/10.jpg)
Utah State
Can be extended (nesting)
rachelSwimLessons = false;
if (rachelMood == “brave”) {
if (weather != “thunder and lightning”) {
if (pool == “open”) {
rachelSwimLessons = true;
}
}
}
![Page 11: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/11.jpg)
Utah State
Logical operators
rachelSwimLessons = false;
if (rachelMood == “brave” && weather != “thunder and lightning” && pool == “open”) {
rachelSwimLessons = true;
}
![Page 12: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/12.jpg)
Utah State
Using else if and else
if(face.currentFrame < 4) {faceState.text = “I’m sad.”;
} else if (face.currentFrame > 8) {faceState.text = “I’m happy.”;
} else {faceState.text = “I’m ok.”;
}/* borrowed with permission from Alan
Wayman, 2007—based on an .fla file he adapted and sent via email. */
![Page 13: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/13.jpg)
Utah State
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 linesasyouneed */
![Page 14: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/14.jpg)
Utah State
Debugging
Control->Debug Movie Lets you watch variable values (and properties) Two kinds of errors:
Logic Syntax
Other option: trace();
![Page 15: Utah State Variables, Debugging, Control Structures.](https://reader035.fdocuments.net/reader035/viewer/2022062516/56649d555503460f94a3225c/html5/thumbnails/15.jpg)
Utah State
Don’t forget
Library folders Layer folders