Pay Your Dues

 

Quick Assignment

Post to ARTLAB/Moller/jkhazar/Upload_Download

Emails Please!

Some still Missing:

Bull
Jaffarzadeh

Errata

 

Naming movieClips

For brevity, let's call it a symbol when it's in the library, and a movieClip when it's on the stage.

Importing graphics

In Flash...

Remember Variables?

 

Containers, Nothing More

A jar of strawberry jam is all about the jam, not the jar. Take out the strawberry jam and put in motor oil and you have a jar of motor oil, not a strawberry jam of motor oil.

Datatypes Again

Strings
Numbers
Booleans
And...objects like arrays
And...movieClip objects specifically
And...button objects specifically
And...functions

demo...

actionScript is "loosely typed"

demo...

var myNumber = 1;
var myString = "1";
var myBoolean = true;
var myClip = circle_mc;
var myArray = [1, 2, 3, 4];

var myFunction = function(){

x=1;

}

trace(typeof(myNumber));
trace(typeof(myString));
trace(typeof(myBoolean));
trace(typeof(myClip));
trace(typeof(myArray));

What happens when you combine datatypes?

Try these:

myNumberAndString
myNumberAndBoolean
myNumberAndFunction

Clash of the Titans: reserved words

MovieClips have timelines

Insensitive So-And-So

Theoretically not upper and lower case sensitive

myVariable is the same as myvariable

gotoAndPlay() is the same as gotoandplay()

BUT

typeof() is NOT the same as typeOf();

Best practice: Pretend like it does matter.

What Goes In Must Come Out*

 

Inputs and Outputs

Text Fields

Three types of text in flash,

Static (the default)
Dynamic
Input

Static

What it says
About fonts...

Input Text settings

demo...
border, lines, max characters, var, character...
Instance name is: myInput_txt.text
Var: myInputVar

Dynamic Text setting, AKA Output

demo...
myOutput_txt
var: is myInputVar
Tada! echo echo echo

Control

demo...
remove the echo
add an "ENTER" button

Decisions, Decisions

Build a movie that takes a value, tests it, then jumps to a frame

A simple movie

if/then Fred


stop();

myEnter_btn.onRelease=function(){

if (myInputVar=="Fred"){

gotoAndStop("correct");

}

}

 

A little more complex

if/then/else Fred


stop();

myEnter_btn.onRelease=function(){

if (myInputVar=="Fred"){

gotoAndStop("correct");

}else{

gotoAndPlay("wrong");

}

}

 

And a little more...

if/then/else if/else Fred fred


stop();

myEnter_btn.onRelease=function(){

if (myInputVar=="Fred"){

gotoAndStop("correct");

}else if (myInputVar=="fred"){

myOutputVar=myInputVar;

gotoAndPlay("caps");

}else{

gotoAndPlay("wrong");

}

}

Number and String weirdness with Input Text

myEnter_btn.onRelease=function(){

resultVar=number1Var+number2Var

}

Oops! Concatenation consternation

Why? By default, input text fields are strings.

Two ways to correct, both weird:

myEnter_btn.onRelease=function(){

resultVar = parseFloat(number1Var) + parseFloat(number2Var);

}

or

don't use +

other operands work, but + can be taken two ways and Flash converts the number to a string

Flag! You're It!

Try this:

stop();

var flagStatusVar = false;

clickMe_btn.onRelease = function() {

flagStatusVar = true;

};

continue_btn.onRelease = function() {

if (flagStatusVar == true) {

gotoAndStop("ok");

}else{

errorVar="click the button first!";

}

};

Bean Counters

Try this:

var flagStatusVar = false;

var errorCount = 0;

clickMe_btn.onRelease = function() {

flagStatusVar = true;

};

continue_btn.onRelease = function() {

if (flagStatusVar == true) {

gotoAndStop("ok");

}else{

errorVar="you've blown it " + errorCount + " times.";

errorCount++;

}

if (errorCount > 5){

gotoAndStop("fool");

}

};

Review

Variables, Datatypes, Text Types, Logical Branching, Flags, Counters

Quiz One

Target start time: 5PM

 

Secret URL

Announced in class

Exercises

 

Datatypes

Iterate 6 paired combinations this + that combinations of...

var myNumber = 1;

var myString = "1";

var myBoolean = true;

var myClip = circle_mc;

var myArray = [1, 2, 3, 4];

var myFunction = function(){

x=1;

}

... and show what value the return and what datatype they are. For example:

myNumberAndString = myNumber + myString;

}trace("myNumberAndString equals " + myNumberAndString + ", which is a " + typeof(myNumberAndString);

Dynamic Text

Build a movie that looks more and behaves more or less like this:

And uses a callback function to update a dynamic text field with an input text field.

Hint:
myEnter_btn.onRelease=function(){...

Advanced

Build a movie that branches based on some text input.

Build a movie that sets a flag and branches.

Build a movie that sets a counter and branches.

 

 

* Teslacale's Deviant,
see also Fudd's Law: If you push something hard enough, it will fall over.