Thursday, January 13, 2011

Week One Notes

Reviewing Flash
We are not using the time-line.
Properties Tab - click on stuff and get info like position and stroke. All of the properties in the properties palette is also accessible via action scripting.
Library Pallete - when we create shapes they go into the library.
     ie. make a square with the tool, click on Modify (at the top), select convert to symbol

     Shapes
     Button has interactivity built into it.
     Movie clip like a graphic but has its own time, independant of the main timeline.
     Registration point  (you can set it, usually we pick the top left corner or the center)


After creating the square into the library, anytime it appears on the stage it will be an instance of that original square in the library.We have to name that instance so we can call it up in the AS.


We are going to be camelCasing to nameStuff.
For Movieclips we are going to name are instances like this:   blueSquare_mc
       Text:  someWords_txt
       Buttons:   clickyThing_btn

Scripting window : F9 for the Actions Palette
In AS3 all the script is in one place, as opposed to tied to objects like AS2

    (if you get an error message when you open of the actions palette, you probably have an object selected on the stage. You have to unselect the object or you can click on the Layer1 : Frame 1

---------------

Variables: they are like a container that holds data. They can hold lots of different types of data.
var myFirstVariable = 255;

the numbers can be decimals

Data Classing = telling it what kind of data the variable contains
   var myFirstVariable:Number = 255;
  (all classes following the naming convention that they are capitalized)
  once you class you a variable it can only hold that kind of information, so if you class it as Number it can
  only hold numbers.

Comments:
// blah blah Single Line comment
/* blah blah blah Multi Line Comment */

Commonly used Data Classes
 Number
 int
 uint
String
Array


var myFirstVariable:Number = 255; //Any number including decimals
var myInteger:int = -35; // Any whole number including positive or negative
var myUnsignedInteger:uint // any non-negative whole number 
var myString:String = "hello";  //just plain text
var myArray: Array = [2,3,4,5]; // list of more than one value in a single variable

Conditionals
A structure in AS that allows flash to evaluate a condition and take a certain path. This is what separates programming language from mark-up language.

// IF STATEMENT

var a:Number = 0;
var b:String = "Ross";
var c:Boolean = false;

if ( a == 1 )   /* you use 2 equal signs because it is an operator, used for conditions to distinguish it from a single = which is like setting the value of something */

if ( a == 1 ) {
    //code goes here  
}


//   TRACE COMMAND
trace("Ross");  // traces to the output panel
trace ("Higgins");
trace (c);

//Control > Test Movie > Test to check this command in the Output Panel

----------------------New page of Code----------------------------
var a:Number = 0;
var b:String = "Ross";
var c:Boolean = false;

if (a==1) {
    //code goes here
    trace("if statement #1 was true");
}

if ( b=="george") {
    trace("Hello George");
} else {
    trace("Hello");
}
/* when you test this code the Output should say Hello, because b = "Ross". IF b ="george" it would say Hello George. */
------------------------Added more to the above code----------------------------


var a:Number = 0;
var b:String = "Ross";
var c:Boolean = false;

if (a == 1) {
    //code goes here
    trace("if statement #1 was true");
}

if (b == "george") {
    trace("Hello George");
} else {
    trace("Hello");
}

if (a==0) {
    trace ("number one is true");
} else if (b=="Ross") {
    trace("number two is true");
} else if (c==true) {
    trace("number three is true");
} else {
    trace("none of these are true");
}

//in this, if a=true then you will see "number one is true" in the output. if a and b are true you will still only get "number one is true" because with this code once it evaluates something and finds it to be true it stops there.


-------------------------------Class Break----------------------------
// OPERATORS

== equality operator
> greater than
< less than
>= greater than or equal to
<= less than or equal to

! not operator
!= not equal to

+ addition
- subtraction
* multiplication
/ division
&& and operator
|| or operator  // this looks weird on blogger, hold shift and hit \ two times


 if (a==1 && b=="Ross") {
     trace("both are true");
 }
 if (b=="Ross" || c==false) {
     trace ("at least one of these are true");
 }

 if (!c) {  //shorthand for (c==false) because c is boolean
    trace("the variable is false");
}
if (a!=1) {
    trace("the variable does not equal 1");
}
if (b!="ross") {
    trace("the varaible does not equal the string ross");
}

------------------New Code---------------
var a:Number = 0;
var b:String = "Ross";
var c:Boolean = false;

//SWITCH

/*
switch ("George") {
    case "ross":
        trace("one");
       
    case "George":
        trace("two");
       
    case "Ross":
        trace("three");
} */

/* switch - in the case that the value = "ross" it will trace "one"
      once it finds one that is true then it continues to run all the code aftre it
      so, in this case you will get  "two" and "three"
      even though "George" is not case "Ross"
      --You have to add BREAK to stop it from running*/

switch ("George") {
    case "ross":
        trace("one");
       
    case "George":
        trace("two");
        break;
       
    case "Ross":
        trace("three");
        break;
    default:
         trace ("other");
}

No comments:

Post a Comment