programming in as3 the basics

22
Programming with Action Script 3.0 the basics

Upload: joseph-burchett

Post on 14-Jan-2015

757 views

Category:

Technology


1 download

DESCRIPTION

These are the slides for the first time I have ever taught a class. It was on learning the core concepts of learning how action script 3.0.

TRANSCRIPT

Page 1: Programming in as3 the basics

Programming with Action Script 3.0 the basics

Page 2: Programming in as3 the basics

What to expect

1. Little over two hours of hardcore Action Script fun!

2. You will probably forget most of it all3. Don't feel bad if you don't get it, study

session after it all is done.4. There is never a stupid question, if you

don't get it speak up!5. Probably moving your car at least once...

Page 3: Programming in as3 the basics

Why should I trust you to teach me anything?

1. I have been worked on both games and enterprise applications using Action Script

2. Experience using Action Script and Flash for well over 6 years now.

3. I enjoy helping others, so ask questions!

Page 4: Programming in as3 the basics

It's all one big game!

1. Each player will gain community xp to level up their character in meetup

2. Everyone's rank will be of "newb" in the community, leveling will be figured out later.

3. For doing the hello world.4. Your avatar will be your meetup image, all data will be represented

eventually on Sacgamehub.com5. One xp point is given based on certain conditions

a. Coming on timeb. Having tools setup alreadyc. Helping out fellow studentd. Completing queste. Defeating the bossf. Random encounter success (random question asked)

3. Leader board of players with most xp counted up at the end of the day.4. Quests are completed by student completing project in time given during presentation5. treasure for completing a quest is candy :-D

You all are adventures on your own quests for knowledge, each quest making you stronger

Page 5: Programming in as3 the basics

What's the agenda for today?1. Explain the format of the class2. Get everyone set up with their tools3. Quick intro into Flash and Action Script 3.04. Do simple "Hello World" on the screen5. Outline core concepts will be going over6. Go over first core concept "Variables"7. Go over second core concept "Collections"8. 10 minute break9. Go over third core concept "Conditionals"

10. Go over fifth core concept "Loops"11. 10 minute break12. Go over sixth core concept "functions"13. Go over seventh core concept "error handling"14. Project using everything learned15. Q&A16. Where to go from here?17. Study time18. Thanks for coming :-D

Page 6: Programming in as3 the basics

Explain format of class

1. Quick lecture on core concept2. Quick Q&A on concept3. Show written example4. Show example5. Class tries it out for themselves6. Repeat it three times7. Exercise doing something new with concept8. Everyone shows their work

Page 7: Programming in as3 the basics

Get everyone set up with their tools1. Download and setup FDT2. Point it to the proper SDK3. Install the debug Flash Player4. Get everyone to join google hangout5. Bookmark http://help.adobe.

com/en_US/FlashPlatform/reference/actionscript/3/index.html

Page 8: Programming in as3 the basics

What is Flash?

What is the Flash Player? Is a multimedia platform that allows you to create really engaging applications for the web, mobile, and desktop space.

What is Action Script 3.0? Is the programming language used to build the applications that the Flash Player understands so it can display the contents to the user.

Page 9: Programming in as3 the basics

trace( "Hello world" );

Page 10: Programming in as3 the basics

Core concepts we will focus on! (The quests)

1. Variables/Types2. Collections3. Conditionals statements4. Control-flow statements5. Functions6. Error handling

Page 11: Programming in as3 the basics

Variables/Types Quest

Description: A variable is a named place holder for a value of a certain type.

Goal: var myVariable:String = "hello world";

Objective: Create a variable that says something silly!

Page 12: Programming in as3 the basics

Types we will focus on

1. String: Represents a collection of alphanumeric characters

2. int: Represents an integer, will allow us to do simple math like equations

3. Number: Represents an integer with a decimal value

4. Boolean: Represents either true or false5. Array: Will allow us to store a collection

of different types

Page 13: Programming in as3 the basics

Math QuestDescription: There are different ways to add, subtract, divide and multiply variables using the different operators

Goal: one + two = 3;

Objective: Create two variables that when multiplied equal 10

Note: Go here for more info on other operators you can use http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/operators.html

Page 14: Programming in as3 the basics

Collections Quest

Description: A variable of type Array will allow you to store a collection of values

Goal: var myArray:Array = [1, 2, 3];trace( myArray[0] ); //1

Objective: Create an array where it's third index contains a numeric value.

Note: arrays are always zero indexed and can store any valueNote: each spot in an array is called an index

Page 15: Programming in as3 the basics

ConditionalsExplain: Using a conditional statement such as an "if" statement allows you to create multiple conditions for a particular piece of code.

Example: if ( myVariable == "hello world" ) { trace( "hello world" ); }else { trace( "not hello world" ); }

Exercise: Create a simple conditional statement checking if variable not equal

Page 16: Programming in as3 the basics

More on conditionalsmultiple conditions: if ( myVariable == "hello world" ) { trace( "hello world" ); }else if( myVariable == "not hello world" ) { trace( "not hello world" ); }else { trace( "something else" ); }

Not:if ( myVariable != "hello world" ) { trace( "not hello world" ); }And: if ( myVariable != "hello world" && myVariable != "not hello world" ) { trace( "something else" ); }Or: if ( myVariable != "hello world" || myVariable == "not hello world" ) { trace( "joe is awesome" ); }Greater then:if ( myVariable >= 1 ) { trace( "greater then one" ); }less then:if ( myVariable <= 1 ) { trace( "greater then one" ); }

Page 17: Programming in as3 the basics

Control-flow Quest

Description: Control-flow statements allow you to execute a set piece of code repeatedly based on a given condition.

Goal: while( variable == true ) { trace ( "variable is true" ); }for( var i:int = 0; i < 3; i++ ) { trace( "variable is " + i ); }

Objective: Use one of the control-flow statements and variables to say the word "Hello world" five times.

Page 18: Programming in as3 the basics

Functions QuestDescription: A function is an easy way to repeatedly execute large chunks of code all throughout your program.

Example: public function myHelloWorldFunction():void { trace( "hello world" ); }myHelloWorldFunction();

public function myNewFunction( myHelloWorldVariable:String ):String { return myHelloWorldVariable; }trace ( myNewFunction ( myHelloWorldVariable ) );

public function myMathFunction( one:int, two:int ):int { return one + two; }trace ( myMathFunction ( one, two ) );

Exercise: Return back a silly message of your own

Page 19: Programming in as3 the basics

Boss Battle! :-DIn order to defeat the boss you must utilize everything you have learned to defeat him. Do this by creating a program using all the new skills you have learned today. The program adds bonus of +2 to your total xp if you used all the core concepts which will act as your life. Winning will get you the treasure of more candy and +5 to your xp.

We will use Math.random() in the end and create a loop to fight against the monster hp 15

Page 20: Programming in as3 the basics

Q&A

Page 21: Programming in as3 the basics

WHERE TO GO FROM HERE!1. Experiment more with what you have learned2. Explore the AS3 docs and try out new stuff!3. Go to google and type in "learn actionscript 3.0"4. Come back and take my other classes :-D5. Scribd is a great site for reading e-books on action script 3.0 related topics

here are two books id recommend diving into after this class http://scr.bi/PepTsh and http://scr.bi/Aj4ArC

Page 22: Programming in as3 the basics

Community Achievements

1. Attended your first class!2. Became a Teacher3. Attended 4 game jams!4. Presented your game at a meetup5. Mingled and got 10 business cards6. Started a game team through meetup7. Got a job in the industry using the meetup8. Released a game with an idea you got from

the meetup9. Stayed on the top of the leaderboard for

whole two months