Tuesday, July 24, 2012

DISTANCE LEARNING - CS179.11 A - SEM 01 SY 2012-13

July 24, 2012
Hi, everyone. So for this session, we will be starting with ActionScript. The learning resources below will teach you what ActionScript is, and how to add some ActionScript code to a Flash project - that's going to be what's covered in the video: What is ActionScript?

This next one is a text tutorial. You'll learn how to change the appearance of a move clip symbol using ActionScript code. Along the way, you'll learn a couple of key points:
  • what instance names are and how to assign them to symbol instances
  • what dot syntax is
  • what properties are

Here is the link to the tutorial:
Assigning AS3 instance names and modifying some AS3 movie clip properties

July 26, 2012
We'll start off today by learning about ActionScript 3 variables. We'll begin with this video where I show an example of a variable being used. There's some code in this example that we won't be taking up until we move further into the semester, so don't worry if you don't understand those yet. What I just want to show you in this video is one example of a variable being used.

Here is the link to the video:
An example of a variable being used in ActionScript 3

After watching the video, read this 3 part student guide that explains what variables are and how to create them:

Our next topic is all about functions in ActionScript 3. Let's start off with this video that uses an analogy to try to explain what a function is: ActionScript 3 Functions - An Analogy

After watching that introductory video on functions, move on to the next resources:
Writing Functions
Adding Function Parameters
Creating Optional Parameters in AS3
Local and Global Variables in AS3

July 31, 2012
First, we'll learn about expressions and operators.

An expression is something that evaluates into a single value. For example, the expression 10 + 5 evaluates to a value of 15. The expression 10 - 5 evaluates to a value of 5.

Expressions are made up of operands and operators. In the expression 10 + 5, the operands are 10 and 5, while the operator is the plus sign (+). The operands are the values being manipulated, modified or analyzed in the expression. The operator dictates how these values are to be manipulated, modified or analyzed. For example, the plus operator (+) dictates that the operands will be added. The multiplication operator (*) dictates that the operands be multiplied.

Watch this video to see an example of expressions being used in ActionScript 3 - Expressions and Operators (Video Introduction). Then read this student guide that enumerates many of the different kinds of expressions and operators that can be used in ActionScript 3 - Expressions and Operators in ActionScript 3

Our next topic will be about if statements.

If statements allow you to write some code that will only be processed when certain conditions are met. In other words, simply writing the code doesn't guarantee that those lines will run. Certain conditions have to be met first before the code is executed. It's kind of like a stop light. If the light is green, then you have the go signal to move. If the light is red, then you stop. With if statements, if the condition is true (light is green), then execute the code. If the condition is false (light is red), then don't execute the code.

Here's an example:
if(score >= 75)
     trace("Congratulations! You passed.");

In this example, the trace statement will only run, if the condition is met(in other words, if the condition turns out to be TRUE). The condition specified here is whether the score is greater than or equal to 75. If it is, then go ahead and run the trace statement. If not, then don't do anything.

So in english, this example would basically translate to: IF the score is greater than or equal to 75, then say "Congratulations! You passed.".

Watch this video to learn all about if statements in ActionScript 3 - If Statements - Intro to ActionScript 3.

Then in this next tutorial, we'll learn about the this keyword - The AS3 this keyword and how to randomize the size of a MovieClip instance on the stage.

Lastly, we'll learn all about ActionScript 3 event handling. This part is very important, so please pay extra attention to this part. Also, make sure that you've already read the tutorial on Assigning AS3 instance names and modifying some AS3 movie clip properties and the tutorials on functions before you start reading this. Those tutorials are from some of the previous sessions.

Again, this is very important so make sure you spend some time on this.

Here are the links to the student guide on ActionScript 3 event handling:
Part 1: Introduction to AS3 event handling
Part 2: How to create an AS3 event listener
Part 3: The AS3 event object

We also have an activity on this, so please log on to our moodle page and look for the activity called Simple Button Events.

August 9, 2012
Here are the students guides for today's session:
Classes and Object in ActionScript 3
Properties and Methods in ActionScript 3

August 14, 2012

Topics for today are:
  • the AS3 Timer class
  • the ENTER_FRAME event

We'll start with the Timer class. Here are the learning activities:
Introduction to the Flash ActionScript 3.0 Timer Class
Creating a Simple Countdown Timer in Flash Using ActionScript 3

Up next is the ENTER_FRAME event.

In our introductory lesson on event handling, we used mouse events as examples. Recall the MouseEvent.CLICK event - this event occurs whenever you click on a button or movie clip (movie clips are also clickable). So here, the event is pretty obvious - when the user clicks, then the CLICK event occurs.

But with the ENTER_FRAME event, it isn't very obvious, because this event gets dispatched even though there seems to be nothing that's happening in the Flash movie. You can just be watching an empty Flash movie, and not clicking on anything or pressing any keyboard keys, but behind the scenes, the ENTER_FRAME event is happening. And not only that, the ENTER_FRAME event happens repeatedly at a constant rate. With a mouse click, the event only happens every time the user clicks on a button or movie clip. This doesn't happen at a steady rate. It's very arbitrary. It just depends on when the user decides to click on something, which we can't always predict.

As for the ENTER_FRAME event, this event gets dispatched at the same rate as the frame rate of your Flash movie. So if you have a frame rate of 30fps, then the ENTER_FRAME event gets dispatched 30 times every one second. And just to reiterate, it gets dispatched even if nothing is happening in the Flash movie. As long as the movie is open, then the ENTER_FRAME event gets dispatched. Nothing else has to happen. And the Flash movie can even be completely empty! Kinda weird, right?

Try this. Create a new ActionScript 3 document and add this code on the first keyframe:
this.addEventListener(Event.ENTER_FRAME, onEnter);

function onEnter(e:Event):void

When you test the movie, Flash will just keep displaying the "Hello!" message in the output window repeatedly. If you're frame rate is 24fps, then this means that Flash will say "Hello!" in the output window 24 times for every second that the movie is running. And it won't stop until you close the movie.

Now close the movie and then change your document's frame rate down to 1fps. Then test the movie again. You'll still see the message displayed repeatedly, but this time, it will be much slower. Since your frame rate is down to 1 frame per second, then this means that the ENTER_FRAME event listener function gets called only once per second.

Now close the movie, and don't forget to bring your frame rate back up. You can just set it to around 24 fps.

So when would I want to use an ENTER_FRAME event listener?

This event is useful if you want to create an event listener function that runs constantly. It really could be about anything. It could be a function that constantly updates a text field. It could be a function that contains an if statement so you could constantly check whether a certain condition is being met or not. It could be anything you need. As long as it's something that you want Flash to do repeatedly while the movie is running, then you might want to consider an ENTER_FRAME event listener as one of your options.

To give you a more concrete example, here is a video tutorial that makes use of the ENTER_FRAME event to create some code-driven animation. This is probably one of the most common uses for the ENTER_FRAME event. Instead of using tweens, the animation is done using code - Using the AS3 EnterFrame Event to
Create Animation in Flash

August 28, 2012

Today's topic: working with text fields using ActionScript 3.

Here are the links to the student guides:

AS3 TextFields - The Basics
Working with AS3 Input Text Fields
Formatting Text in AS3
ActionScript 3 String to Number Conversion
ActionScript 3 Number to String Conversion
Enabling the User to Submit the Contents Inside an Input Text Field
[PART 1] Working with External Text in Flash ActionScript 3 - Loading the Text
[PART 2] Working with External Text in Flash ActionScript 3 - Formatting the Text
[PART 3] Working with External Text in Flash ActionScript 3 - Scrolling the Text

September 4, 2012

For this day's session, we will learn how to control sound using ActionScript 3. Here are the links to the student guides:

Student Guide: Introduction to Working with Sound in AS3
Student Guide: Playing Sound from the Library and Making a Sound Clip Loop in AS3
Student Guide: Pausing Sound in ActionScript 3.0
Student Guide: Creating a Simple Volume Bar in Flash
Student Guide: Adjusting Volume in ActionScript 3.0

September 18, 2012

This week's lessons are about Arrays and For Loops in ActionScript 3:

Arrays in ActionScript 3
For Loops in ActionScript 3
Creating a Simple Quiz in Flash Using AS3
Creating Multiple TextFields and Positioning Them Using Arrays and for Loops in Flash ActionScript 3.0
Retreiving the Index Value of an Item in an Array in Flash AS3

No comments:

Post a Comment