SlideShare a Scribd company logo
ARTDM 170, Week 5:
 Intro to Adobe Flash
         Gilbert Guerrero
        gguerrero@dvc.edu
gilbertguerrero.com/blog/artdm-170
Please turn in homework

• Last weekʼs homework was to create a
  Web page that used jQuery
• Put files in a folder with your lastname
  and first initial
• Example:
       smith-h
          myPage.html
          pic1.jpg
Group Projects
Adobe Flash
Open Flash and create a new
 ActionScript 3.0 document...
Basic ActionScript

• Click the first Keyframe in the
  timeline to select it
• Open the ActionScript window by
  going to Window > Actions
Trace output
  trace(“Hello World!”);

• Go to Control > Test Movie to test out
  your ActionScript
• trace helps troubleshoot code by
  sending notes to you in the Output
  window
Screen Output
var myText:TextField = new TextField();
myText.text = "Hello World!";
addChild(myText);

• The first line creates a new area to display
  the text, a textfield
• The second line puts your text in the
  textfield
• The third line adds the textfield to the stage
Display Objects
  var myText:TextField =
    new TextField();

• Visual elements that appear in
  ActionScript
• Such as textfields, graphics, buttons,
  movie clips, and user interface
  components
Object Properties
  myText.text =
    "Hello World!";

• Objects have properties
• Each object has itʼs own properties
• Properties of the objects can be
  changed directly
Display Lists
  addChild(myText);

• Creating objects does not add them
  to the stage. You must place them
  directly.
The Stage

• The main movie area where
 everything takes place that the user
 will see
The Library

• Where youʼll store all the media
  thatʼs associated with your Flash
  movie
The Timeline

• Frames
• Keyframes
• In-between Frames
• Empty Keyframes
• Labels
• Layers
Writing ActionScript
ActionScript Window

• Wonʼt use most of the buttons until
  you get used to ActionScript
• Use the Show/Hide Toolbox button to
  collapse the left column
• Disable Script Assist for now
Comments
    // single comment

    /*
    multi-line comment
    */
•   Comments are notes you can add for
    yourself or other developers
•   Comments can also be used to “turn off”
    code
Use descriptive naming

• Variable names:
               tennisBall,
  userRacket, userScore

• Function names: hitBall(
                        ),
  calcScore( ), headPunch( )
Use functions

• Use functions for repetitive tasks or
  tasks that appear in many places
  public function showTime() {
    timeDisplay.text =
      “Time: ” + timeElapsed;
  }

  showTime();
ActionScript Logic
if-else statements
if (this is true) {
    then do this
}
if-else statements
if (this is true) {
    then do this
} else {
    do this
}
if-else statements
if (this is true) {
    then do this
} else if (this is true) {
    then do this
} else {
    do this
}
Equal, not equal, or...
•   Assume this: a = 1;
                 b = 2;
                 c = 1;

•   These are true statements:
    (a == c)  a is equal to c
    (a != b)   a is not equal to b
    (a == 1 || c == 1)  a is equal to 1 or c is equal to 1
    (b > a)  b is greater than a
    (a >= c) a is greater than or equal to c
    (a + c == b) a plus c is equal to b
Variable Types

 • When they first appear, they must
   be declared using var
 • Variable type must also be
   declared (after the colon):

   var moveX:Number = 10;
Variable types
  Primitive:              Complex: 
  Boolean                 Object
  int                     Array
  null                    Date
  Number                  Error
                          Function
  String
                          RegExp
  uint
                          XML
  undefined                XMLList
• Declare any data type using an asterisk (*):
  var myX:*;
Placement

• An instance of a movie clip can be
 positioned at any location by
 assigning values to the x and y as
 coordinates:
myClip.x = 300;
myClip.y = 200;
Movement

• An instance of a movie clip can be
  moved by adding a value to x or y:
  myClip.x = myClip.x + 50;
  myClip.y = myClip.y + 50;
ActionScript Classes
Object Oriented Programming

• Object Oriented Programming (OOP)
  is way of writing code that uses
  objects as building blocks
• Your application can have many
  objects, each based on a single
  blueprint called a class
• Objects can have properties which is
  the data that makes each object
  unique
External ActionScript Files

• To place ActionScript in an external
  file, rather than embedding it in
  frames on the timeline, weʼre
  required to use OOP
• Weʼll be creating an ActionScript
  class to store our code
Your first ActionScript class

• Save your Flash file as
  HelloWorld2.fla
• Go to New... > ActionScript File   to
  create a new external AS file
• Save the file using the same name
  as your Flash file, example:
  HelloWorld2.as
ActionScript Class
package {
  import flash.display.*;
  import flash.text.*;


    public class HelloWorld extends MovieClip {


        public function HelloWorld() {
          var myText: TextField = new TextField();
          myText.text = "Hello World!";
          addChild(myText);
        }
    }
}
ActionScript Class
                Class file declaration
package {                  Library classes needed
  import flash.display.*;
  import flash.text.*;                Class definition
    public class HelloWorld2 extends MovieClip {


        public function HelloWorld2() {
          var myText: TextField = new TextField();
          myText.text = "Hello World!";
          addChild(myText);
        }
    }                                   Constructor
}
Constructors

• A constructor is a function that
  executes as soon as the class loads
• Must be named the same as the
  class
• Other functions come afterward
Putting it together

• To use the class in your Flash movie
  you must associate it with the movie.
• In the Properties panel associate the
  external AS file with HelloWorld.fla
  by typing the filename into the class
  field
Event Listeners
•   By using an event listener that's triggered by
    ENTER_FRAME the movie clip instance will move
    on it's own
    addEventListener(Event.ENTER_FRAME, myFunction);

    myBtn.addEventListener(MouseEvent.CLICK, myFunction);
Homework, due March 2

• Read p41-64, Chapter 2:
 ActionScript Game Elements in AS
 3.0 Game Programming University
Thank You

More Related Content

What's hot (18)

PDF
JavaScript in 2016
Codemotion
 
PDF
TypeScript for Java Developers
Yakov Fain
 
PPTX
25csharp
Sireesh K
 
PPT
Lesson3
Arpan91
 
PPTX
Extending javascript part one
Vijaya Anand
 
PDF
Few simple-type-tricks in scala
Ruslan Shevchenko
 
PDF
TypeScript 2 in action
Alexander Rusakov
 
PPTX
Java Static Factory Methods
Ye Win
 
PPT
Basic info on java intro
kabirmahlotra
 
PDF
Scalable JavaScript Design Patterns
Addy Osmani
 
PPT
Unit ii
snehaarao19
 
PDF
Objective c runtime
Inferis
 
PDF
Extending Node.js using C++
Kenneth Geisshirt
 
PDF
React Native Evening
Troy Miles
 
PDF
JavaScript Good Practices
Jussi Pohjolainen
 
ODP
Scala Future & Promises
Knoldus Inc.
 
PPTX
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
ODP
From object oriented to functional domain modeling
Codemotion
 
JavaScript in 2016
Codemotion
 
TypeScript for Java Developers
Yakov Fain
 
25csharp
Sireesh K
 
Lesson3
Arpan91
 
Extending javascript part one
Vijaya Anand
 
Few simple-type-tricks in scala
Ruslan Shevchenko
 
TypeScript 2 in action
Alexander Rusakov
 
Java Static Factory Methods
Ye Win
 
Basic info on java intro
kabirmahlotra
 
Scalable JavaScript Design Patterns
Addy Osmani
 
Unit ii
snehaarao19
 
Objective c runtime
Inferis
 
Extending Node.js using C++
Kenneth Geisshirt
 
React Native Evening
Troy Miles
 
JavaScript Good Practices
Jussi Pohjolainen
 
Scala Future & Promises
Knoldus Inc.
 
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
From object oriented to functional domain modeling
Codemotion
 

Similar to Artdm170 Week5 Intro To Flash (20)

KEY
Coding Flash : ActionScript(3.0) Tutorial
PEI-YAO HUNG
 
PDF
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
Unity Technologies Japan K.K.
 
KEY
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
KEY
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
KEY
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
KEY
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
KEY
Artdm170 week6 scripting_motion
Gilbert Guerrero
 
PPT
Objective c
ricky_chatur2005
 
DOCX
IT 511 Final Project Guidelines and Grading Guide Ov.docx
priestmanmable
 
PDF
Louis Loizides iOS Programming Introduction
Lou Loizides
 
PPTX
Customizing the Presentation Model and Physical Renderer in Siebel Open UI
Tech OneStop
 
PPTX
Chapter iii(oop)
Chhom Karath
 
PDF
iOS Programming Intro
Lou Loizides
 
PPTX
Lecture 4- Javascript Function presentation
GomathiUdai
 
PDF
The Ring programming language version 1.2 book - Part 5 of 84
Mahmoud Samir Fayed
 
PPTX
Group111
Shahriar Robbani
 
PPTX
introduction to c #
Sireesh K
 
PPTX
Csharp introduction
Sireesh K
 
PPT
Google tools for webmasters
Rujata Patil
 
Coding Flash : ActionScript(3.0) Tutorial
PEI-YAO HUNG
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
Unity Technologies Japan K.K.
 
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
Artdm170 week6 scripting_motion
Gilbert Guerrero
 
Objective c
ricky_chatur2005
 
IT 511 Final Project Guidelines and Grading Guide Ov.docx
priestmanmable
 
Louis Loizides iOS Programming Introduction
Lou Loizides
 
Customizing the Presentation Model and Physical Renderer in Siebel Open UI
Tech OneStop
 
Chapter iii(oop)
Chhom Karath
 
iOS Programming Intro
Lou Loizides
 
Lecture 4- Javascript Function presentation
GomathiUdai
 
The Ring programming language version 1.2 book - Part 5 of 84
Mahmoud Samir Fayed
 
introduction to c #
Sireesh K
 
Csharp introduction
Sireesh K
 
Google tools for webmasters
Rujata Patil
 
Ad

More from Gilbert Guerrero (20)

PPTX
Designing for Skepticism and Bright Sunlight
Gilbert Guerrero
 
KEY
ARTDM 171, Week 17: Usability Testing and QA
Gilbert Guerrero
 
KEY
Artdm 171 week15 seo
Gilbert Guerrero
 
KEY
Artdm 170 week15 publishing
Gilbert Guerrero
 
KEY
ARTDM 171, Week 14: Forms
Gilbert Guerrero
 
KEY
ARTDM 170, Week 13: Text Elements + Arrays
Gilbert Guerrero
 
KEY
ARTDM 170, Week 14: Introduction to Processing
Gilbert Guerrero
 
KEY
ARTDM 171, Week 13: Navigation Schemes
Gilbert Guerrero
 
KEY
Artdm170 week12 user_interaction
Gilbert Guerrero
 
KEY
Artdm 171 Week12 Templates
Gilbert Guerrero
 
KEY
ARTDM 171, Week 10: Mood Boards + Page Comps
Gilbert Guerrero
 
KEY
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
Gilbert Guerrero
 
KEY
ARTDM 171, Week 9: User Experience
Gilbert Guerrero
 
KEY
ARTDM 171, Week 7: Remapping Cyberspace
Gilbert Guerrero
 
KEY
ARTDM 170, Week 7: Scripting Interactivity
Gilbert Guerrero
 
KEY
Artdm171 Week6 Images
Gilbert Guerrero
 
KEY
Artdm171 Week5 Css
Gilbert Guerrero
 
KEY
Artdm171 Week4 Tags
Gilbert Guerrero
 
KEY
Artdm170 Week4 Java Script Effects
Gilbert Guerrero
 
KEY
ARTDM 171, Week 3: Web Basics + Group Projects
Gilbert Guerrero
 
Designing for Skepticism and Bright Sunlight
Gilbert Guerrero
 
ARTDM 171, Week 17: Usability Testing and QA
Gilbert Guerrero
 
Artdm 171 week15 seo
Gilbert Guerrero
 
Artdm 170 week15 publishing
Gilbert Guerrero
 
ARTDM 171, Week 14: Forms
Gilbert Guerrero
 
ARTDM 170, Week 13: Text Elements + Arrays
Gilbert Guerrero
 
ARTDM 170, Week 14: Introduction to Processing
Gilbert Guerrero
 
ARTDM 171, Week 13: Navigation Schemes
Gilbert Guerrero
 
Artdm170 week12 user_interaction
Gilbert Guerrero
 
Artdm 171 Week12 Templates
Gilbert Guerrero
 
ARTDM 171, Week 10: Mood Boards + Page Comps
Gilbert Guerrero
 
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
Gilbert Guerrero
 
ARTDM 171, Week 9: User Experience
Gilbert Guerrero
 
ARTDM 171, Week 7: Remapping Cyberspace
Gilbert Guerrero
 
ARTDM 170, Week 7: Scripting Interactivity
Gilbert Guerrero
 
Artdm171 Week6 Images
Gilbert Guerrero
 
Artdm171 Week5 Css
Gilbert Guerrero
 
Artdm171 Week4 Tags
Gilbert Guerrero
 
Artdm170 Week4 Java Script Effects
Gilbert Guerrero
 
ARTDM 171, Week 3: Web Basics + Group Projects
Gilbert Guerrero
 
Ad

Recently uploaded (20)

PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PDF
Stepwise procedure (Manually Submitted & Un Attended) Medical Devices Cases
MUHAMMAD SOHAIL
 
PPTX
THE JEHOVAH’S WITNESSES’ ENCRYPTED SATANIC CULT
Claude LaCombe
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PDF
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
PPTX
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PDF
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
PPTX
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
PDF
John Keats introduction and list of his important works
vatsalacpr
 
PPTX
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
 
PPTX
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
PPTX
FAMILY HEALTH NURSING CARE - UNIT 5 - CHN 1 - GNM 1ST YEAR.pptx
Priyanshu Anand
 
PPTX
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Stepwise procedure (Manually Submitted & Un Attended) Medical Devices Cases
MUHAMMAD SOHAIL
 
THE JEHOVAH’S WITNESSES’ ENCRYPTED SATANIC CULT
Claude LaCombe
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
John Keats introduction and list of his important works
vatsalacpr
 
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
 
Applied-Statistics-1.pptx hardiba zalaaa
hardizala899
 
FAMILY HEALTH NURSING CARE - UNIT 5 - CHN 1 - GNM 1ST YEAR.pptx
Priyanshu Anand
 
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 

Artdm170 Week5 Intro To Flash

  • 1. ARTDM 170, Week 5: Intro to Adobe Flash Gilbert Guerrero [email protected] gilbertguerrero.com/blog/artdm-170
  • 2. Please turn in homework • Last weekʼs homework was to create a Web page that used jQuery • Put files in a folder with your lastname and first initial • Example:      smith-h myPage.html pic1.jpg
  • 4. Adobe Flash Open Flash and create a new ActionScript 3.0 document...
  • 5. Basic ActionScript • Click the first Keyframe in the timeline to select it • Open the ActionScript window by going to Window > Actions
  • 6. Trace output trace(“Hello World!”); • Go to Control > Test Movie to test out your ActionScript • trace helps troubleshoot code by sending notes to you in the Output window
  • 7. Screen Output var myText:TextField = new TextField(); myText.text = "Hello World!"; addChild(myText); • The first line creates a new area to display the text, a textfield • The second line puts your text in the textfield • The third line adds the textfield to the stage
  • 8. Display Objects var myText:TextField = new TextField(); • Visual elements that appear in ActionScript • Such as textfields, graphics, buttons, movie clips, and user interface components
  • 9. Object Properties myText.text = "Hello World!"; • Objects have properties • Each object has itʼs own properties • Properties of the objects can be changed directly
  • 10. Display Lists addChild(myText); • Creating objects does not add them to the stage. You must place them directly.
  • 11. The Stage • The main movie area where everything takes place that the user will see
  • 12. The Library • Where youʼll store all the media thatʼs associated with your Flash movie
  • 13. The Timeline • Frames • Keyframes • In-between Frames • Empty Keyframes • Labels • Layers
  • 15. ActionScript Window • Wonʼt use most of the buttons until you get used to ActionScript • Use the Show/Hide Toolbox button to collapse the left column • Disable Script Assist for now
  • 16. Comments // single comment /* multi-line comment */ • Comments are notes you can add for yourself or other developers • Comments can also be used to “turn off” code
  • 17. Use descriptive naming • Variable names: tennisBall, userRacket, userScore • Function names: hitBall( ), calcScore( ), headPunch( )
  • 18. Use functions • Use functions for repetitive tasks or tasks that appear in many places public function showTime() { timeDisplay.text = “Time: ” + timeElapsed; } showTime();
  • 20. if-else statements if (this is true) {     then do this }
  • 21. if-else statements if (this is true) {     then do this } else {     do this }
  • 22. if-else statements if (this is true) {     then do this } else if (this is true) {     then do this } else {     do this }
  • 23. Equal, not equal, or... • Assume this: a = 1; b = 2; c = 1; • These are true statements: (a == c)  a is equal to c (a != b)   a is not equal to b (a == 1 || c == 1)  a is equal to 1 or c is equal to 1 (b > a)  b is greater than a (a >= c) a is greater than or equal to c (a + c == b) a plus c is equal to b
  • 24. Variable Types • When they first appear, they must be declared using var • Variable type must also be declared (after the colon): var moveX:Number = 10;
  • 25. Variable types Primitive: Complex:  Boolean Object int Array null Date Number Error Function String RegExp uint XML undefined  XMLList • Declare any data type using an asterisk (*): var myX:*;
  • 26. Placement • An instance of a movie clip can be positioned at any location by assigning values to the x and y as coordinates: myClip.x = 300; myClip.y = 200;
  • 27. Movement • An instance of a movie clip can be moved by adding a value to x or y: myClip.x = myClip.x + 50; myClip.y = myClip.y + 50;
  • 29. Object Oriented Programming • Object Oriented Programming (OOP) is way of writing code that uses objects as building blocks • Your application can have many objects, each based on a single blueprint called a class • Objects can have properties which is the data that makes each object unique
  • 30. External ActionScript Files • To place ActionScript in an external file, rather than embedding it in frames on the timeline, weʼre required to use OOP • Weʼll be creating an ActionScript class to store our code
  • 31. Your first ActionScript class • Save your Flash file as HelloWorld2.fla • Go to New... > ActionScript File to create a new external AS file • Save the file using the same name as your Flash file, example: HelloWorld2.as
  • 32. ActionScript Class package { import flash.display.*; import flash.text.*; public class HelloWorld extends MovieClip { public function HelloWorld() { var myText: TextField = new TextField(); myText.text = "Hello World!"; addChild(myText); } } }
  • 33. ActionScript Class Class file declaration package { Library classes needed import flash.display.*; import flash.text.*; Class definition public class HelloWorld2 extends MovieClip { public function HelloWorld2() { var myText: TextField = new TextField(); myText.text = "Hello World!"; addChild(myText); } } Constructor }
  • 34. Constructors • A constructor is a function that executes as soon as the class loads • Must be named the same as the class • Other functions come afterward
  • 35. Putting it together • To use the class in your Flash movie you must associate it with the movie. • In the Properties panel associate the external AS file with HelloWorld.fla by typing the filename into the class field
  • 36. Event Listeners • By using an event listener that's triggered by ENTER_FRAME the movie clip instance will move on it's own addEventListener(Event.ENTER_FRAME, myFunction); myBtn.addEventListener(MouseEvent.CLICK, myFunction);
  • 37. Homework, due March 2 • Read p41-64, Chapter 2: ActionScript Game Elements in AS 3.0 Game Programming University