際際滷

際際滷Share a Scribd company logo
Unit 7: Making Decisions
and Repeating Yourself
Topics
 Iteration (looping) statements
 index loop: looping over arrays
 Conditional statements
 if / else
 comparison operators: > >= < <= == != instanceof
 logical operators: || && !
What is a Loop" Statement?
 A loop ("iteration") statement re-executes specified
code until a condition is met
 ActionScript supports four different loop statements
 for
 for-in
 while
 do-while
Using Index Loops and their Values
for (Index") Loop
 Counts from one number to another
 Most commonly used
Bucle while
var aNames:Array = ["Fred", "Ginger", "Sam"];
while(aNames.length > 0)
{
trace("Names in array: " + aNames.length);
trace(aNames.pop());
}
El bucle while se ejecuta mientras su condici坦n sea verdadera.
Si nunca cambia nada en el c坦digo del bucle como para que la
condici坦n pase a ser falsa, se estar叩 creando un bucle sin fin.
Bucle do  while
var aNames:Array = [];
do
{
trace("Names in array: " + aNames.length);
trace(aNames.pop());
} while(aNames.length > 0)
El bucle do-while siempre se ejecuta por lo menos una vez.
Despu辿s, contin炭a ejecut叩ndose mientras su condici坦n siga siendo verdadera.
En el c坦digo, ver鱈a Names in array: 0,
aun cuando la condici坦n es falsa,
porque la longitud de aNames no supera 0 y
la condici坦n no se ha comprobado hasta despu辿s
de que el c坦digo del bucle se ha ejecutado.
 AttachingMultipleMovieClipsfrom anArray ofData
 Loop over the length of an array
 Trace index variables
 Use index variables to create unique instance names
 Use index variables to assign unique positions
 Assign arrayvalues for display in a dynamically generated MovieClip instance
Walkthrough7-1
Using Conditional Statements
What's a Conditional Statement"?
 A conditional statement tests whether one or more
comparison expressions are true
 If the entire condition is true, specified code executes,
else other tests or default code may execute
 ActionScript supports three types of conditional
statements
 if / else
 switch / case (not covered)
 Conditional operator (not covered)
What's a Comparison Expression"?
 ActionScript supports seven main comparison
expressions
 Is it true that
 x > y x is greater than y ?
 x >= y x is greater than or equivalent to y ?
 x < y x is less than y ?
 x <= y x is less than or equivalent to y ?
 x == y x is equivalent (not "equals") to y ?
 x != y x is not equivalent to y ?
 x instanceof y x is an instance of a class named y
How Does it Look in Code?
 If the expression is true, the code block executes
var password:String = "fly";
if (txtPassword.text == password) {
// runs if User typed "fly" in the password field
}
if (aPlayers instanceof Array) {
// runs if aPlayers is an instance of the Array class
}
How Do I Ask if Something is False?
 ActionScript supports a "not" logical operator
 Is it true that 
 !(this is true)
 is this expression not true (is it false)?
var password:String = "fly";
if (!(txtPassword.text == password)) {
// runs if User typed anything but "fly" in txtPassword
}
if (!(aPlayers instanceof Array)) {
// runs if aPlayers is anything but an Array
}
How Do I Ask More Than One Question at a Time?
 ActionScript supports "and" and "or" logical operators
 Is it true that
 This is true && ("and") this is true
 Are both expressions true?
 This is true || ("or") this is true
 Is either expression true?
How Does It Look in Code?
 If the entire compound expression is true, the code will
execute
if (expression1 && expression2) {
// runs if expressions 1 and 2 are both true
}
if (expression3 || !(expression4)) {
// runs if expression 3 is true or 4 is not true
}
How Does It Look in Code?
 If the entire compound expression is true, the code will
execute
if (txtPassword.text == "fly" && player.admin == true) {
adminMode(true);
}
if (player.highScore < 200 || !(player.status == "expert"))
{
easyMode(true);
}
Can I Ask Alternative Questions?
 An else if clause is tested only if the prior if is not true
 Otherwise each if is separately tested
if (txtPassword.text == "fly") {
adminMode(true);
}
else if (player.highScore < 200) {
easyMode(true);
}
Can I Have a Default?
 An else clause executes if none of the above are true
if (txtPassword.text == "fly") {
adminMode(true);
}
else if (player.highScore < 200) {
easyMode(true);
}
else
{
regularMode(true);
}
Can I Nest My Conditions?
 Conditions may be nested, if a second condition only
makes sense if a prior condition is true
if (this._rotation <= 0) {
this._xscale = this._xscale  10;
if(this._xscale <= 0) {
this.unloadMovie();
}
}
 VisuallyTogglinga MovieClipusingConditionalCode
 Test the value of visual properties
 Conditionally change MovieClip properties between states
Walkthrough7-2
 RespondingtoRandom RotationandDynamicallyGeneratingMultiple
MovieClips
 Randomly calculate the change rate of a property
 Test to ensure a calculation is only made once
 Test for and respond to changes in property values
 Call a function a specified number of times
 Observing that each instance of MovieClip symbol is unique
Lab7
Unit 8: Animating with ActionScript
Topics
 Implementing drag and drop functionality for a MovieClip
 Hit ("collision") testing between MovieClip instances
 Using an initialization object in the attachMovie method
 Using the onEnterFrame event handler
 Working with animation velocity and conditionally testing Stage
bounds
Dragging, Dropping, and
Hit Testing MovieClip Objects
startDrag() and stopDrag() are MovieClip methods
ball1.onPress = function():Void {
How Do I Let the User Pick up a MovieClip Instance
and Move It?
Every symbol instance has a bounding box
What's the Difference Between a Bounding Box and
Shape?
hitTest() is a MovieClip method which returns true or false if
its bounding box or shape is touching either a target MovieClip
How Do I Know if Two Objects are Touching?
 Dragging,Dropping,andHit TestingMovieClipObjects
 Use onPress and onRelease event handler methods
 Use the startDrag and stopDrag methods
 Respond to collisions when dropping an object
Walkthrough8-1
Initializing MovieClip Objects
with an onEnterFrame Event Handler
Timeline animation occurs when the playhead enters a
keyframe with different content than before
When Does Flash Animation" Occur?
ActionScript 9-10
MovieClip instances broadcast the onEnterFrame event ("signal") each
time the playhead enters a frame
What's the onEnterFrame Event?
Initialization objects are generic objects passed as an optional
argument to the attachMovie() method
How Do I Initialize" an Attached MovieClip?
Velocity or the change rate of an animated MovieClip may
need to be calculated or change at run time
Why Make Velocity" a Variable?
 InitializingAttachedMovieClipswithan onEnterFrameHandler
 Use an initialization object when attaching MovieClip objects
 Use the onEnterFrame event handler
 Randomly calculate velocity (change rate) for two dimensions
 Test for Stage boundaries during animation
 Hit test during animation
Walkthrough8-2

More Related Content

What's hot (20)

Battle of The Mocking Frameworks
Battle of The Mocking FrameworksBattle of The Mocking Frameworks
Battle of The Mocking Frameworks
Dror Helper
Exception Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in RubyException Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in Ruby
Wen-Tien Chang
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsWhitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applications
Yura Nosenko
Pi j4.2 software-reliability
Pi j4.2 software-reliabilityPi j4.2 software-reliability
Pi j4.2 software-reliability
mcollison
Flow Control (C#)
Flow Control (C#)Flow Control (C#)
Flow Control (C#)
Bhushan Mulmule
Mock with Mockito
Mock with MockitoMock with Mockito
Mock with Mockito
Camilo Lopes
Java object oriented programming - OOPS
Java object oriented programming - OOPSJava object oriented programming - OOPS
Java object oriented programming - OOPS
rithustutorials
Testing Spring Boot application in post-JUnit 4 world
Testing Spring Boot application in post-JUnit 4 worldTesting Spring Boot application in post-JUnit 4 world
Testing Spring Boot application in post-JUnit 4 world
Yura Nosenko
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummies
Harry Potter
Practical unit testing 2014
Practical unit testing 2014Practical unit testing 2014
Practical unit testing 2014
Andrew Fray
Java exception handling
Java exception handlingJava exception handling
Java exception handling
rithustutorials
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
Ying Zhang
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
myrajendra
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Code
slicklash
BDD style Unit Testing
BDD style Unit TestingBDD style Unit Testing
BDD style Unit Testing
Wen-Tien Chang
Exceptions in Java
Exceptions in JavaExceptions in Java
Exceptions in Java
Vadym Lotar
Nalinee java
Nalinee javaNalinee java
Nalinee java
Nalinee Choudhary
Decision statements
Decision statementsDecision statements
Decision statements
Jaya Kumari
Kill the mutants - A better way to test your tests
Kill the mutants - A better way to test your testsKill the mutants - A better way to test your tests
Kill the mutants - A better way to test your tests
Roy van Rijn
Java Exception Handling
Java Exception HandlingJava Exception Handling
Java Exception Handling
DeeptiJava
Battle of The Mocking Frameworks
Battle of The Mocking FrameworksBattle of The Mocking Frameworks
Battle of The Mocking Frameworks
Dror Helper
Exception Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in RubyException Handling: Designing Robust Software in Ruby
Exception Handling: Designing Robust Software in Ruby
Wen-Tien Chang
Whitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applicationsWhitebox testing of Spring Boot applications
Whitebox testing of Spring Boot applications
Yura Nosenko
Pi j4.2 software-reliability
Pi j4.2 software-reliabilityPi j4.2 software-reliability
Pi j4.2 software-reliability
mcollison
Mock with Mockito
Mock with MockitoMock with Mockito
Mock with Mockito
Camilo Lopes
Java object oriented programming - OOPS
Java object oriented programming - OOPSJava object oriented programming - OOPS
Java object oriented programming - OOPS
rithustutorials
Testing Spring Boot application in post-JUnit 4 world
Testing Spring Boot application in post-JUnit 4 worldTesting Spring Boot application in post-JUnit 4 world
Testing Spring Boot application in post-JUnit 4 world
Yura Nosenko
Google mock for dummies
Google mock for dummiesGoogle mock for dummies
Google mock for dummies
Harry Potter
Practical unit testing 2014
Practical unit testing 2014Practical unit testing 2014
Practical unit testing 2014
Andrew Fray
Java exception handling
Java exception handlingJava exception handling
Java exception handling
rithustutorials
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
Ying Zhang
Types of exceptions
Types of exceptionsTypes of exceptions
Types of exceptions
myrajendra
Working Effectively with Legacy Code
Working Effectively with Legacy CodeWorking Effectively with Legacy Code
Working Effectively with Legacy Code
slicklash
BDD style Unit Testing
BDD style Unit TestingBDD style Unit Testing
BDD style Unit Testing
Wen-Tien Chang
Exceptions in Java
Exceptions in JavaExceptions in Java
Exceptions in Java
Vadym Lotar
Decision statements
Decision statementsDecision statements
Decision statements
Jaya Kumari
Kill the mutants - A better way to test your tests
Kill the mutants - A better way to test your testsKill the mutants - A better way to test your tests
Kill the mutants - A better way to test your tests
Roy van Rijn
Java Exception Handling
Java Exception HandlingJava Exception Handling
Java Exception Handling
DeeptiJava

Similar to ActionScript 9-10 (20)

Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
Akash Pandey
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
Edureka!
Loops in java script
Loops in java scriptLoops in java script
Loops in java script
Ravi Bhadauria
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
Rohit Rao
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
MadhurRajVerma1
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
Tarunsingh198
Java teaching ppt for the freshers in colleeg.ppt
Java teaching ppt for the freshers in colleeg.pptJava teaching ppt for the freshers in colleeg.ppt
Java teaching ppt for the freshers in colleeg.ppt
vvsofttechsolution
Java Tutorial | My Heart
Java Tutorial | My HeartJava Tutorial | My Heart
Java Tutorial | My Heart
Bui Kiet
3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf
santosh147365
Java tut1
Java tut1Java tut1
Java tut1
Sumit Tambe
Java tut1
Java tut1Java tut1
Java tut1
Sumit Tambe
Javatut1
Javatut1 Javatut1
Javatut1
desaigeeta
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
Graham Royce
Programming fundamentals through javascript
Programming fundamentals through javascriptProgramming fundamentals through javascript
Programming fundamentals through javascript
Codewizacademy
Java_Tutorial_Introduction_to_Core_java.ppt
Java_Tutorial_Introduction_to_Core_java.pptJava_Tutorial_Introduction_to_Core_java.ppt
Java_Tutorial_Introduction_to_Core_java.ppt
Govind Samleti
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
ArnaldoCanelas
Java tutorials
Java tutorialsJava tutorials
Java tutorials
QUAID-E-AWAM UNIVERSITY OF ENGINEERING, SCIENCE & TECHNOLOGY, NAWABSHAH, SINDH, PAKISTAN
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
Dror Helper
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
All Things Open
Pitfalls Of Tdd Adoption by Bartosz Bankowski
Pitfalls Of Tdd Adoption by Bartosz BankowskiPitfalls Of Tdd Adoption by Bartosz Bankowski
Pitfalls Of Tdd Adoption by Bartosz Bankowski
Agileee
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
Edureka!
Loops in java script
Loops in java scriptLoops in java script
Loops in java script
Ravi Bhadauria
2. overview of c#
2. overview of c#2. overview of c#
2. overview of c#
Rohit Rao
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
Tarunsingh198
Java teaching ppt for the freshers in colleeg.ppt
Java teaching ppt for the freshers in colleeg.pptJava teaching ppt for the freshers in colleeg.ppt
Java teaching ppt for the freshers in colleeg.ppt
vvsofttechsolution
Java Tutorial | My Heart
Java Tutorial | My HeartJava Tutorial | My Heart
Java Tutorial | My Heart
Bui Kiet
3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf3. Flow Controls in C (Part II).pdf
3. Flow Controls in C (Part II).pdf
santosh147365
Java tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo CahersiveenJava tut1 Coderdojo Cahersiveen
Java tut1 Coderdojo Cahersiveen
Graham Royce
Programming fundamentals through javascript
Programming fundamentals through javascriptProgramming fundamentals through javascript
Programming fundamentals through javascript
Codewizacademy
Java_Tutorial_Introduction_to_Core_java.ppt
Java_Tutorial_Introduction_to_Core_java.pptJava_Tutorial_Introduction_to_Core_java.ppt
Java_Tutorial_Introduction_to_Core_java.ppt
Govind Samleti
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
Dror Helper
We Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End DevelopmentWe Are All Testers Now: The Testing Pyramid and Front-End Development
We Are All Testers Now: The Testing Pyramid and Front-End Development
All Things Open
Pitfalls Of Tdd Adoption by Bartosz Bankowski
Pitfalls Of Tdd Adoption by Bartosz BankowskiPitfalls Of Tdd Adoption by Bartosz Bankowski
Pitfalls Of Tdd Adoption by Bartosz Bankowski
Agileee

Recently uploaded (20)

How to use Init Hooks in Odoo 18 - Odoo 際際滷s
How to use Init Hooks in Odoo 18 - Odoo 際際滷sHow to use Init Hooks in Odoo 18 - Odoo 際際滷s
How to use Init Hooks in Odoo 18 - Odoo 際際滷s
Celine George
How to Configure Restaurants in Odoo 17 Point of Sale
How to Configure Restaurants in Odoo 17 Point of SaleHow to Configure Restaurants in Odoo 17 Point of Sale
How to Configure Restaurants in Odoo 17 Point of Sale
Celine George
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
DrNidhiAgarwal
TPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategyTPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategy
Henry Tapper
cervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdfcervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdf
SamarHosni3
A PPT Presentation on The Princess and the God: A tale of ancient India by A...
A PPT Presentation on The Princess and the God: A tale of ancient India  by A...A PPT Presentation on The Princess and the God: A tale of ancient India  by A...
A PPT Presentation on The Princess and the God: A tale of ancient India by A...
Beena E S
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
A PPT on the First Three chapters of Wings of Fire
A PPT on the First Three chapters of Wings of FireA PPT on the First Three chapters of Wings of Fire
A PPT on the First Three chapters of Wings of Fire
Beena E S
Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025
Conquiztadors- the Quiz Society of Sri Venkateswara College
Rass MELAI : an Internet MELA Quiz Prelims - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Prelims - El Dorado 2025Rass MELAI : an Internet MELA Quiz Prelims - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Prelims - El Dorado 2025
Conquiztadors- the Quiz Society of Sri Venkateswara College
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptxFESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
DanmarieMuli1
The Broccoli Dog's inner voice (look A)
The Broccoli Dog's inner voice  (look A)The Broccoli Dog's inner voice  (look A)
The Broccoli Dog's inner voice (look A)
merasan
Kaun TALHA quiz Finals -- El Dorado 2025
Kaun TALHA quiz Finals -- El Dorado 2025Kaun TALHA quiz Finals -- El Dorado 2025
Kaun TALHA quiz Finals -- El Dorado 2025
Conquiztadors- the Quiz Society of Sri Venkateswara College
Chapter 3. Social Responsibility and Ethics in Strategic Management.pptx
Chapter 3. Social Responsibility and Ethics in Strategic Management.pptxChapter 3. Social Responsibility and Ethics in Strategic Management.pptx
Chapter 3. Social Responsibility and Ethics in Strategic Management.pptx
Rommel Regala
Fuel part 1.pptx........................
Fuel part 1.pptx........................Fuel part 1.pptx........................
Fuel part 1.pptx........................
ksbhattadcm
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdfBlind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Ajaz Hussain
Adventure Activities Final By H R Gohil Sir
Adventure Activities Final By H R Gohil SirAdventure Activities Final By H R Gohil Sir
Adventure Activities Final By H R Gohil Sir
GUJARATCOMMERCECOLLE
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
sandynavergas1
EDL 290F Week 3 - Mountaintop Views (2025).pdf
EDL 290F Week 3  - Mountaintop Views (2025).pdfEDL 290F Week 3  - Mountaintop Views (2025).pdf
EDL 290F Week 3 - Mountaintop Views (2025).pdf
Liz Walsh-Trevino
Year 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptxYear 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptx
mansk2
How to use Init Hooks in Odoo 18 - Odoo 際際滷s
How to use Init Hooks in Odoo 18 - Odoo 際際滷sHow to use Init Hooks in Odoo 18 - Odoo 際際滷s
How to use Init Hooks in Odoo 18 - Odoo 際際滷s
Celine George
How to Configure Restaurants in Odoo 17 Point of Sale
How to Configure Restaurants in Odoo 17 Point of SaleHow to Configure Restaurants in Odoo 17 Point of Sale
How to Configure Restaurants in Odoo 17 Point of Sale
Celine George
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...SOCIAL CHANGE(a change in the institutional and normative structure of societ...
SOCIAL CHANGE(a change in the institutional and normative structure of societ...
DrNidhiAgarwal
TPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategyTPR Data strategy 2025 (1).pdf Data strategy
TPR Data strategy 2025 (1).pdf Data strategy
Henry Tapper
cervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdfcervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdf
SamarHosni3
A PPT Presentation on The Princess and the God: A tale of ancient India by A...
A PPT Presentation on The Princess and the God: A tale of ancient India  by A...A PPT Presentation on The Princess and the God: A tale of ancient India  by A...
A PPT Presentation on The Princess and the God: A tale of ancient India by A...
Beena E S
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
A PPT on the First Three chapters of Wings of Fire
A PPT on the First Three chapters of Wings of FireA PPT on the First Three chapters of Wings of Fire
A PPT on the First Three chapters of Wings of Fire
Beena E S
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptxFESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
FESTIVAL: SINULOG & THINGYAN-LESSON 4.pptx
DanmarieMuli1
The Broccoli Dog's inner voice (look A)
The Broccoli Dog's inner voice  (look A)The Broccoli Dog's inner voice  (look A)
The Broccoli Dog's inner voice (look A)
merasan
Chapter 3. Social Responsibility and Ethics in Strategic Management.pptx
Chapter 3. Social Responsibility and Ethics in Strategic Management.pptxChapter 3. Social Responsibility and Ethics in Strategic Management.pptx
Chapter 3. Social Responsibility and Ethics in Strategic Management.pptx
Rommel Regala
Fuel part 1.pptx........................
Fuel part 1.pptx........................Fuel part 1.pptx........................
Fuel part 1.pptx........................
ksbhattadcm
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdfBlind spots in AI and Formulation Science, IFPAC 2025.pdf
Blind spots in AI and Formulation Science, IFPAC 2025.pdf
Ajaz Hussain
Adventure Activities Final By H R Gohil Sir
Adventure Activities Final By H R Gohil SirAdventure Activities Final By H R Gohil Sir
Adventure Activities Final By H R Gohil Sir
GUJARATCOMMERCECOLLE
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
Eng7-Q4-Lesson 1 Part 1 Understanding Discipline-Specific Words, Voice, and T...
sandynavergas1
EDL 290F Week 3 - Mountaintop Views (2025).pdf
EDL 290F Week 3  - Mountaintop Views (2025).pdfEDL 290F Week 3  - Mountaintop Views (2025).pdf
EDL 290F Week 3 - Mountaintop Views (2025).pdf
Liz Walsh-Trevino
Year 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptxYear 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptx
mansk2

ActionScript 9-10

  • 1. Unit 7: Making Decisions and Repeating Yourself
  • 2. Topics Iteration (looping) statements index loop: looping over arrays Conditional statements if / else comparison operators: > >= < <= == != instanceof logical operators: || && !
  • 3. What is a Loop" Statement? A loop ("iteration") statement re-executes specified code until a condition is met ActionScript supports four different loop statements for for-in while do-while
  • 4. Using Index Loops and their Values
  • 5. for (Index") Loop Counts from one number to another Most commonly used
  • 6. Bucle while var aNames:Array = ["Fred", "Ginger", "Sam"]; while(aNames.length > 0) { trace("Names in array: " + aNames.length); trace(aNames.pop()); } El bucle while se ejecuta mientras su condici坦n sea verdadera. Si nunca cambia nada en el c坦digo del bucle como para que la condici坦n pase a ser falsa, se estar叩 creando un bucle sin fin.
  • 7. Bucle do while var aNames:Array = []; do { trace("Names in array: " + aNames.length); trace(aNames.pop()); } while(aNames.length > 0) El bucle do-while siempre se ejecuta por lo menos una vez. Despu辿s, contin炭a ejecut叩ndose mientras su condici坦n siga siendo verdadera. En el c坦digo, ver鱈a Names in array: 0, aun cuando la condici坦n es falsa, porque la longitud de aNames no supera 0 y la condici坦n no se ha comprobado hasta despu辿s de que el c坦digo del bucle se ha ejecutado.
  • 8. AttachingMultipleMovieClipsfrom anArray ofData Loop over the length of an array Trace index variables Use index variables to create unique instance names Use index variables to assign unique positions Assign arrayvalues for display in a dynamically generated MovieClip instance Walkthrough7-1
  • 10. What's a Conditional Statement"? A conditional statement tests whether one or more comparison expressions are true If the entire condition is true, specified code executes, else other tests or default code may execute ActionScript supports three types of conditional statements if / else switch / case (not covered) Conditional operator (not covered)
  • 11. What's a Comparison Expression"? ActionScript supports seven main comparison expressions Is it true that x > y x is greater than y ? x >= y x is greater than or equivalent to y ? x < y x is less than y ? x <= y x is less than or equivalent to y ? x == y x is equivalent (not "equals") to y ? x != y x is not equivalent to y ? x instanceof y x is an instance of a class named y
  • 12. How Does it Look in Code? If the expression is true, the code block executes var password:String = "fly"; if (txtPassword.text == password) { // runs if User typed "fly" in the password field } if (aPlayers instanceof Array) { // runs if aPlayers is an instance of the Array class }
  • 13. How Do I Ask if Something is False? ActionScript supports a "not" logical operator Is it true that !(this is true) is this expression not true (is it false)? var password:String = "fly"; if (!(txtPassword.text == password)) { // runs if User typed anything but "fly" in txtPassword } if (!(aPlayers instanceof Array)) { // runs if aPlayers is anything but an Array }
  • 14. How Do I Ask More Than One Question at a Time? ActionScript supports "and" and "or" logical operators Is it true that This is true && ("and") this is true Are both expressions true? This is true || ("or") this is true Is either expression true?
  • 15. How Does It Look in Code? If the entire compound expression is true, the code will execute if (expression1 && expression2) { // runs if expressions 1 and 2 are both true } if (expression3 || !(expression4)) { // runs if expression 3 is true or 4 is not true }
  • 16. How Does It Look in Code? If the entire compound expression is true, the code will execute if (txtPassword.text == "fly" && player.admin == true) { adminMode(true); } if (player.highScore < 200 || !(player.status == "expert")) { easyMode(true); }
  • 17. Can I Ask Alternative Questions? An else if clause is tested only if the prior if is not true Otherwise each if is separately tested if (txtPassword.text == "fly") { adminMode(true); } else if (player.highScore < 200) { easyMode(true); }
  • 18. Can I Have a Default? An else clause executes if none of the above are true if (txtPassword.text == "fly") { adminMode(true); } else if (player.highScore < 200) { easyMode(true); } else { regularMode(true); }
  • 19. Can I Nest My Conditions? Conditions may be nested, if a second condition only makes sense if a prior condition is true if (this._rotation <= 0) { this._xscale = this._xscale 10; if(this._xscale <= 0) { this.unloadMovie(); } }
  • 20. VisuallyTogglinga MovieClipusingConditionalCode Test the value of visual properties Conditionally change MovieClip properties between states Walkthrough7-2
  • 21. RespondingtoRandom RotationandDynamicallyGeneratingMultiple MovieClips Randomly calculate the change rate of a property Test to ensure a calculation is only made once Test for and respond to changes in property values Call a function a specified number of times Observing that each instance of MovieClip symbol is unique Lab7
  • 22. Unit 8: Animating with ActionScript
  • 23. Topics Implementing drag and drop functionality for a MovieClip Hit ("collision") testing between MovieClip instances Using an initialization object in the attachMovie method Using the onEnterFrame event handler Working with animation velocity and conditionally testing Stage bounds
  • 24. Dragging, Dropping, and Hit Testing MovieClip Objects
  • 25. startDrag() and stopDrag() are MovieClip methods ball1.onPress = function():Void { How Do I Let the User Pick up a MovieClip Instance and Move It?
  • 26. Every symbol instance has a bounding box What's the Difference Between a Bounding Box and Shape?
  • 27. hitTest() is a MovieClip method which returns true or false if its bounding box or shape is touching either a target MovieClip How Do I Know if Two Objects are Touching?
  • 28. Dragging,Dropping,andHit TestingMovieClipObjects Use onPress and onRelease event handler methods Use the startDrag and stopDrag methods Respond to collisions when dropping an object Walkthrough8-1
  • 29. Initializing MovieClip Objects with an onEnterFrame Event Handler
  • 30. Timeline animation occurs when the playhead enters a keyframe with different content than before When Does Flash Animation" Occur?
  • 32. MovieClip instances broadcast the onEnterFrame event ("signal") each time the playhead enters a frame What's the onEnterFrame Event?
  • 33. Initialization objects are generic objects passed as an optional argument to the attachMovie() method How Do I Initialize" an Attached MovieClip?
  • 34. Velocity or the change rate of an animated MovieClip may need to be calculated or change at run time Why Make Velocity" a Variable?
  • 35. InitializingAttachedMovieClipswithan onEnterFrameHandler Use an initialization object when attaching MovieClip objects Use the onEnterFrame event handler Randomly calculate velocity (change rate) for two dimensions Test for Stage boundaries during animation Hit test during animation Walkthrough8-2