Final Project: Remote controlled character

Requirements:

Create a character in a profile view (side view). When creating this character, remember that it will need to be animated! So if all your artwork is on one layer you are on the wrong track. Instead, break up your character into many layers that will allow for easier animating.

There is a minimum of 3 movement animations required for this project. There has to be a walking animation and a jumping animation, leaving the third movement up to you to decide.

These animations will need to be controlled by buttons  on the stage. So for each movement that your character can preform, there needs to be an associated button to control the character, i.e. a jump button, walk button, etc.

For the walking animation, we not only need to animate the character walking but we also need to move him/her across the screen. We will do this by adding or subtracting to the character’s x position, depending on which directing he/she is facing. Since we are going to be moving the character across the screen, we also need to prevent him/her for walking out off view, and turn him/her around so that he/she can walk back in the other direction.

Grading:

40% of this grade will go to the quality of your artwork and your animations. If little to no effort was made on these drawings and/or your animations are sketchy and jagged, you will lose points.

60% will go to the actionscript portion of the assignment. Full credit will be awarded if the student successfully implements all of the three buttons to control their respective animations. As well as successful detection of the edge of the stage while the character is walking, and turning him around so that he can walk in the opposite direction. Any missing functionality will result in loss of points.

 

Week 10: November 8th

Sorry guys, tonight’s class is canceled. Please check your mercer email for more information.

Mercer has scheduled a make up class for last week’s hurricane on December 13th.

Week 9: In Class Practical – Conditional Statements

For each exercise, create a new file and name as directed. When you are done place all files in a folder with your name inside the week 9 practical folder on dropbox.

In this practical we are going to learn to make decisions in our code. The way we make decisions in programming is through conditional statements. Basically in plain english the code works like this:

If this is true, then do this.

In code it looks like this:

if(<YOUR CONDITION HERE>) {
//Do stuff
}

Exercise 1

  • Create a new flash file and name it conditions.fla
  • set up your actions layer and open the actions panel
  • Create a variable called myBool with the data type, Boolean and set it equal to true
  • now write a conditional statement testing myBool
  • Inside the condition block (aka the curly braces) run a trace statement outputing a string saying “myBool is equal to true”
  • Test the movie and you should see the message appear in the output window
  • Now try setting myBool equal to false and test the movie again. you should not see the message appear now

 

Exercise 2

So testing if a variable equals true is pretty basic, to step it up a notch lets use some conditional operators:

> Is Greater than
< Is Less than
== Is Equal to
  • Create a new flash file and name it conditional-operators.fla
  • set up your actions layer and open the actions panel
  • Create twos variable called num1 and num2 with the data type Number, and set num1 equal 1 and num2  equal to 2
  • now write 3 conditional statements each using a different conditional operator (>, <, ==) testing the two variables, num1 and num2
  • Inside each of the 3 condition blocks (aka the curly braces) run a trace statement outputing a string that explains the condition.
    • The Is Greater Than condition message should be “num1 is greater than num2″
    • The Is Less Than condition message should be “num1 is less than num2″
    • The Is Equal To condition message should be “num1 is equal to num2″
  • Test the movie and you should  only see the message  form the Is Less than condition appear in the output window. That is because 1 is less than 2.
  • Now try changing the values of num1 and num2 to and test the movie again and see what messages appear

 

Exercise 3

Ok now what if we want to do something no matter what? So in plain english:

If this is true, then do this
if it isn't true, do this instead

In code this is called an if-else conditional statement, which allows us to run one set of code if the condition we test is true and another set of code if the condition is false. it looks like this:

if(<YOUR CONDITION HERE>) {
//Do stuff
} else {
//Okay, do this instead
}
  • Create a new flash file and name it if-else-conditions.fla
  • set up your actions layer and open the actions panel
  • Create twos variable called num1 and num2 with the data type Number, and set num1 equal 1 and num2  equal to 2
  • now write an if-else conditional statement testing num1 IsGreater Than num2
  • Inside the if condition block (aka the curly braces) trace the message “num1 is greater than num2″
  • Inside the else condition block (aka the curly braces) trace the message “num1 is not greater than num2″
  • Test the movie and see what message appears
  • Now try changing the values of num1 and num2 to and test the movie again and see what messages appear now

 

 

Week 9: October 25th

Agenda:

  • Critique of Project 3
  • ActionScript – Conditional statements
  • In Class Practical
Note on grades

I will be getting all grades up to date this weekend and I will send out an email to the class when they are up. Should be no later than Sunday night.

Assignments:

  • Lynda Videos – Actionscript Essential Training chapters 4, 6, and 7
  • Blog Assignment –  Research Object Oriented Programming and write an explanation of what it is. Also, define the following concepts in OOP:
    • Encapsulation
    • Inheritance
    • Polymorphism
    • Classes
    • Objects
    • Properties
    • Methods

Proper naming conventions

Remember function, variable, and parameter names can be anything you like, as long as they are not the same as a Flash reserved word, such as  ”trace” or “var” Also they cannot contain spaces or special characters

Function Names and Variable names should also be in “camelCase” which means the first word should start in lowercase and each following word should be capitalized

Examples of correct names:

  • mySum
  • addTenTimes
  • mySum2
  • hello
  • helloWorld

Examples of incorrect names:

  • MySum
  • add ten times!
  • addTenTimes&$&#*
  • hello-world

Week 9: Intro to Actionscript Review

Using what we learned in last week’s Practical, complete the following assignment.

Create a new file and call it, “intro-review.fla”

  • Set up your actions layer and open the actions panel
  • Create a function that accepts 2 number parameters and returns a number value
  • Name the function addTenTimes
  • Name the parameters num1 and num2
  • Inside the function block (aka the curly braces), create a new variable called total which will be set equal to the sum of the first parameter, num1 and the second parameter, num2.
  • So now we have the sum of the two parameters stored inside the variable total, but we called the function addTenTimes, so we should actually do that.
  • So next try on your own to add the value of num2  to the total the remaining nine times
  • When you have the final value return it back out of the function using the return statement
  • Now that you have the function created call the function, but remember it is returning a number value so you should catch that value as well by storing it in a variable. You can call this variable myFunctionResult
  • Lastly, trace the value of  myFunctionResult so that when you test the movie the value is displayed in the output window

Week 8: In Class Practical – Intro to Actionscript 3.0

For this practical, we are going to work with the basics of programming in actionscript:

  • Variables
  • Data Types
  • Trace()
  • Math Operators
  • Functions
  • Function Parameters
  • Function Return Values

For each of the following exercises, create a new file and place it in a folder with your name in the week 8 practical folder on dropbox. By the end of the Practical you should have 4 separate files in your folder, one for each exercise.

1. Working with variables and simple math:

  • Create a new flash file and call it simple_math.fla. Create a layer called “actions” and be sure that it is locked so you do not mistakenly add any art work to it.
  • Open the actions panel by going to Window>Actions
  • Be sure you are on the “actions” layer on the timeline and you are also on the first frame.
  • Create two variables. Call them num1 and num2
  • Set num1 to be equal to 2
  • Set num2 to be equal to 4
  • **Remember – variable names call be anything as long as the do not contain letters or special characters. Try to keep your variable names short and descriptive
  • Create a new variable called “total” and set it equal to the sum of “num1″ and “num2″
  • Trace the value of “total” and test your movie by going to Control>Test Movie>Test
  • In the Output window you should see the number 6

2. Creating an addition function

  • In this exercise, we will build on exercise 1
  • Open your simple_math.fla file and go to File> Save As to create a copy of it
  • Name the copy adding_function.fla
  • Open the Actions panel once again and make sure you have the”actions” layer selected on the timeline and also make sure you are on frame 1
  • Here you should see the code you wrote in exercise 1
  • At the bottom of the code on a new line create a function and call it “addTwoNumbers” and make sure you set the return type to void
  • Find the code from above where you are adding “num1″ and “num2″ and setting their sum to the variable “total” and place it inside the function block (inside the curly braces)
  • Now find the code where you used the trace function to output the value of “total” and place that inside the function block (inside the curly braces) as well, but be sure it is place after the code the adds “num1″ and “num2″
  • Now that the function is complete we have to call the function, otherwise the code inside will never run
  • To run the function, call it by typing it’s name, in this case the name is “addTwoNumbers” and follow it with an open and close parenthesis and a semicolon
  • Now test your movie like before and you should see 6 appear in the output window once again.

3. Creating a function which accepts parameters

  • Create a Copy of adding_function.fla file and name it function_parameters.fla
  • In this exercise we will modify our function so it will accept two numbers that will be added together.
  • When a function accepts values of any kind those values are referred to as that functions parameters
  • We will start off by giving our parameters names that we can use to identify them
  • We do this by typing the parameter names in the parenthesis in the function definition. For example ours should look like this:
    function addTwoNumbers(firstNum, secondNum):void {
  • “firstNum” and “secondNum” will hold our values and we now have to replace “num1″ with “firstNum”, and “num2″ with “secondNum” inside our function
  • Now where we are calling the function we need to modify it to send our values
    addTwoNumbers(num1, num2);
  • Now call it two other times with any numbers you like
    addTwoNumbers(5, 30);
    addTwoNumbers(44, 100);
  • Test the movie and see if you adding function is working correctly

4. Returning a value from a function

  • Copy the file from exercise 3 to use as a starting point for this exercise and call it function_return_value.fla
  • In this exercise we will address the “:void” portion of our function
  • :void is use when we are not returning a value
  • If we are returning a value though we will need to modify this to say what type of value we would like to return
  • In our case we are dealing with Numbers so our return type will be a number and will look like this
    function addTwoNumbers(5, 30):Number {
  • Now where we are tracing the value of total within the function, we are instead going to return the value of total to the line that called the function.
  • To do this type
    return total;
  • Now our function is returning a value but nothing is currently receiving that value
  • To receive the value go to the line where we are calling the function and modify it to have a new variable called “mySum” be equal to the return value of the function
  • Then on a new line trace the value of “mySum” and test the movie