SlideShare ist ein Scribd-Unternehmen logo
1 von 34
ARTDM 170, Week 5:
 Intro to Adobe Flash
         Gilbert Guerrero
        gguerrero@dvc.edu
gilbertguerrero.com/blog/artdm-170
Homework

• Please turn in your homework
Adobe Flash
Open Flash and create a new
 ActionScript 3.0 document...
Basic Setup

• Click the first Keyframe in the
  timeline to select it
• Open the ActionScript window by
  going to Window > Actions
Trace output

• Add a call to the trace function:
  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
Your first ActionScript class

• Save your ActionScript file
• 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        package {
                       import flash.disp
•   Function that
                       import flash.text
    executes as soon
    as the class loads
                       public class Hell
•   Must be named
    the same as theMovieClip {
    class
• Other functions     public function
    come afterward      var myText: T
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
Display Objects

• Visual elements that appear in
  ActionScript
• Such as textfields, graphics, buttons,
  movie clips, and user interface
  components
• Example:
  var myText: TextField = new TextField();
Object Properties

• Objects have properties
• Each object has itʼs own properties
• Properties of the objects can be
  changed directly
• Example:
  myText.text = "Hello World!";
Display Lists

• Creating objects does not add them
  to the stage. You must place them
  directly.
• Example:
  addChild(myText);
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
•   To add a comment:

    // 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
• Example:
  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
 moved to any location using x and y
 as coordinates:
myClip.x = 300;
myClip.y = 200;
Movement
• An instance of a movie clip can be told to
 move by adding a value to x or y:
// Setup the values
 var moveX:Number = 10;
 var moveY:Number = 10;
// Move the clips
 myClip.x = myClip.x + moveX;
 myClip.y = myClip.y + moveY;
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 Sept 23

• Read Chapter 1, p1-42 in the
  ActionScript 3.0 Cookbook
Thank You

Weitere ähnliche Inhalte

Ähnlich wie ARTDM 170, Week 5: Intro To Flash

Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
Artdm170 week6 scripting_motion
Artdm170 week6 scripting_motionArtdm170 week6 scripting_motion
Artdm170 week6 scripting_motion
Gilbert Guerrero
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
Gilbert Guerrero
 
Java Script basics and DOM
Java Script basics and DOMJava Script basics and DOM
Java Script basics and DOM
Sukrit Gupta
 
IT 511 Final Project Guidelines and Grading Guide Ov.docx
IT 511 Final Project Guidelines and Grading Guide  Ov.docxIT 511 Final Project Guidelines and Grading Guide  Ov.docx
IT 511 Final Project Guidelines and Grading Guide Ov.docx
priestmanmable
 

Ähnlich wie ARTDM 170, Week 5: Intro To Flash (20)

Coding Flash : ActionScript(3.0) Tutorial
Coding Flash :  ActionScript(3.0) TutorialCoding Flash :  ActionScript(3.0) Tutorial
Coding Flash : ActionScript(3.0) Tutorial
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
 
Artdm170 week6 scripting_motion
Artdm170 week6 scripting_motionArtdm170 week6 scripting_motion
Artdm170 week6 scripting_motion
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
 
Artdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting MotionArtdm170 Week6 Scripting Motion
Artdm170 Week6 Scripting Motion
 
The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84The Ring programming language version 1.2 book - Part 5 of 84
The Ring programming language version 1.2 book - Part 5 of 84
 
Louis Loizides iOS Programming Introduction
Louis Loizides iOS Programming IntroductionLouis Loizides iOS Programming Introduction
Louis Loizides iOS Programming Introduction
 
iOS Programming Intro
iOS Programming IntroiOS Programming Intro
iOS Programming Intro
 
Java Script basics and DOM
Java Script basics and DOMJava Script basics and DOM
Java Script basics and DOM
 
IT 511 Final Project Guidelines and Grading Guide Ov.docx
IT 511 Final Project Guidelines and Grading Guide  Ov.docxIT 511 Final Project Guidelines and Grading Guide  Ov.docx
IT 511 Final Project Guidelines and Grading Guide Ov.docx
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev intro
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone development
 
Chapter iii(oop)
Chapter iii(oop)Chapter iii(oop)
Chapter iii(oop)
 
Objective c
Objective cObjective c
Objective c
 
Class introduction in java
Class introduction in javaClass introduction in java
Class introduction in java
 
introduction to c #
introduction to c #introduction to c #
introduction to c #
 
Csharp introduction
Csharp introductionCsharp introduction
Csharp introduction
 
Google tools for webmasters
Google tools for webmastersGoogle tools for webmasters
Google tools for webmasters
 

Mehr von Gilbert Guerrero

ARTDM 171, Week 17: Usability Testing and QA
ARTDM 171, Week 17: Usability Testing and QAARTDM 171, Week 17: Usability Testing and QA
ARTDM 171, Week 17: Usability Testing and QA
Gilbert Guerrero
 
Artdm 170 week15 publishing
Artdm 170 week15 publishingArtdm 170 week15 publishing
Artdm 170 week15 publishing
Gilbert Guerrero
 
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + Arrays
Gilbert Guerrero
 
ARTDM 170, Week 14: Introduction to Processing
ARTDM 170, Week 14: Introduction to ProcessingARTDM 170, Week 14: Introduction to Processing
ARTDM 170, Week 14: Introduction to Processing
Gilbert Guerrero
 
ARTDM 171, Week 13: Navigation Schemes
ARTDM 171, Week 13: Navigation SchemesARTDM 171, Week 13: Navigation Schemes
ARTDM 171, Week 13: Navigation Schemes
Gilbert Guerrero
 
Artdm170 week12 user_interaction
Artdm170 week12 user_interactionArtdm170 week12 user_interaction
Artdm170 week12 user_interaction
Gilbert Guerrero
 
ARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 171, Week 10: Mood Boards + Page CompsARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 171, Week 10: Mood Boards + Page Comps
Gilbert Guerrero
 
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
ARTDM 170, Week 10: Encapsulation + Paper PrototypesARTDM 170, Week 10: Encapsulation + Paper Prototypes
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
Gilbert Guerrero
 
ARTDM 171, Week 9: User Experience
ARTDM 171, Week 9: User ExperienceARTDM 171, Week 9: User Experience
ARTDM 171, Week 9: User Experience
Gilbert Guerrero
 
ARTDM 171, Week 7: Remapping Cyberspace
ARTDM 171, Week 7: Remapping CyberspaceARTDM 171, Week 7: Remapping Cyberspace
ARTDM 171, Week 7: Remapping Cyberspace
Gilbert Guerrero
 
ARTDM 170, Week 7: Scripting Interactivity
ARTDM 170, Week 7: Scripting InteractivityARTDM 170, Week 7: Scripting Interactivity
ARTDM 170, Week 7: Scripting Interactivity
Gilbert Guerrero
 
Artdm170 Week4 Java Script Effects
Artdm170 Week4 Java Script EffectsArtdm170 Week4 Java Script Effects
Artdm170 Week4 Java Script Effects
Gilbert Guerrero
 
ARTDM 171, Week 3: Web Basics + Group Projects
ARTDM 171, Week 3: Web Basics + Group ProjectsARTDM 171, Week 3: Web Basics + Group Projects
ARTDM 171, Week 3: Web Basics + Group Projects
Gilbert Guerrero
 
ARTDM 170, Week 3: Rollovers
ARTDM 170, Week 3: RolloversARTDM 170, Week 3: Rollovers
ARTDM 170, Week 3: Rollovers
Gilbert Guerrero
 
ARTDM 170, Week 3: Rollovers
ARTDM 170, Week 3: RolloversARTDM 170, Week 3: Rollovers
ARTDM 170, Week 3: Rollovers
Gilbert Guerrero
 

Mehr von Gilbert Guerrero (20)

ARTDM 171, Week 17: Usability Testing and QA
ARTDM 171, Week 17: Usability Testing and QAARTDM 171, Week 17: Usability Testing and QA
ARTDM 171, Week 17: Usability Testing and QA
 
Artdm 171 week15 seo
Artdm 171 week15 seoArtdm 171 week15 seo
Artdm 171 week15 seo
 
Artdm 170 week15 publishing
Artdm 170 week15 publishingArtdm 170 week15 publishing
Artdm 170 week15 publishing
 
ARTDM 171, Week 14: Forms
ARTDM 171, Week 14: FormsARTDM 171, Week 14: Forms
ARTDM 171, Week 14: Forms
 
ARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + ArraysARTDM 170, Week 13: Text Elements + Arrays
ARTDM 170, Week 13: Text Elements + Arrays
 
ARTDM 170, Week 14: Introduction to Processing
ARTDM 170, Week 14: Introduction to ProcessingARTDM 170, Week 14: Introduction to Processing
ARTDM 170, Week 14: Introduction to Processing
 
ARTDM 171, Week 13: Navigation Schemes
ARTDM 171, Week 13: Navigation SchemesARTDM 171, Week 13: Navigation Schemes
ARTDM 171, Week 13: Navigation Schemes
 
Artdm170 week12 user_interaction
Artdm170 week12 user_interactionArtdm170 week12 user_interaction
Artdm170 week12 user_interaction
 
ARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 171, Week 10: Mood Boards + Page CompsARTDM 171, Week 10: Mood Boards + Page Comps
ARTDM 171, Week 10: Mood Boards + Page Comps
 
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
ARTDM 170, Week 10: Encapsulation + Paper PrototypesARTDM 170, Week 10: Encapsulation + Paper Prototypes
ARTDM 170, Week 10: Encapsulation + Paper Prototypes
 
ARTDM 171, Week 9: User Experience
ARTDM 171, Week 9: User ExperienceARTDM 171, Week 9: User Experience
ARTDM 171, Week 9: User Experience
 
ARTDM 171, Week 7: Remapping Cyberspace
ARTDM 171, Week 7: Remapping CyberspaceARTDM 171, Week 7: Remapping Cyberspace
ARTDM 171, Week 7: Remapping Cyberspace
 
ARTDM 170, Week 7: Scripting Interactivity
ARTDM 170, Week 7: Scripting InteractivityARTDM 170, Week 7: Scripting Interactivity
ARTDM 170, Week 7: Scripting Interactivity
 
Artdm171 Week6 Images
Artdm171 Week6 ImagesArtdm171 Week6 Images
Artdm171 Week6 Images
 
Artdm171 Week5 Css
Artdm171 Week5 CssArtdm171 Week5 Css
Artdm171 Week5 Css
 
Artdm171 Week4 Tags
Artdm171 Week4 TagsArtdm171 Week4 Tags
Artdm171 Week4 Tags
 
Artdm170 Week4 Java Script Effects
Artdm170 Week4 Java Script EffectsArtdm170 Week4 Java Script Effects
Artdm170 Week4 Java Script Effects
 
ARTDM 171, Week 3: Web Basics + Group Projects
ARTDM 171, Week 3: Web Basics + Group ProjectsARTDM 171, Week 3: Web Basics + Group Projects
ARTDM 171, Week 3: Web Basics + Group Projects
 
ARTDM 170, Week 3: Rollovers
ARTDM 170, Week 3: RolloversARTDM 170, Week 3: Rollovers
ARTDM 170, Week 3: Rollovers
 
ARTDM 170, Week 3: Rollovers
ARTDM 170, Week 3: RolloversARTDM 170, Week 3: Rollovers
ARTDM 170, Week 3: Rollovers
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

ARTDM 170, Week 5: Intro To Flash

  • 1. ARTDM 170, Week 5: Intro to Adobe Flash Gilbert Guerrero gguerrero@dvc.edu gilbertguerrero.com/blog/artdm-170
  • 2. Homework • Please turn in your homework
  • 3. Adobe Flash Open Flash and create a new ActionScript 3.0 document...
  • 4. Basic Setup • Click the first Keyframe in the timeline to select it • Open the ActionScript window by going to Window > Actions
  • 5. Trace output • Add a call to the trace function: 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
  • 6. 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
  • 7. Your first ActionScript class • Save your ActionScript file • 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
  • 8. 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); } } }
  • 9. 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 }
  • 10. Constructors package { import flash.disp • Function that import flash.text executes as soon as the class loads public class Hell • Must be named the same as theMovieClip { class • Other functions public function come afterward var myText: T
  • 11. 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
  • 12. Display Objects • Visual elements that appear in ActionScript • Such as textfields, graphics, buttons, movie clips, and user interface components • Example: var myText: TextField = new TextField();
  • 13. Object Properties • Objects have properties • Each object has itʼs own properties • Properties of the objects can be changed directly • Example: myText.text = "Hello World!";
  • 14. Display Lists • Creating objects does not add them to the stage. You must place them directly. • Example: addChild(myText);
  • 15. The Stage • The main movie area where everything takes place that the user will see
  • 16. The Library • Where youʼll store all the media thatʼs associated with your Flash movie
  • 17. The Timeline • Frames • Keyframes • In-between Frames • Empty Keyframes • Labels • Layers
  • 19. 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
  • 20. Comments • To add a comment: // 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
  • 21. Use descriptive naming • Variable names: tennisBall, userRacket, userScore • Function names: hitBall( ), calcScore( ), headPunch( )
  • 22. Use functions • Use functions for repetitive tasks or tasks that appear in many places • Example: public function showTime() { timeDisplay.text = “Time: ” + timeElapsed; } showTime();
  • 24. if-else statements if (this is true) {     then do this }
  • 25. if-else statements if (this is true) {     then do this } else {     do this }
  • 26. if-else statements if (this is true) {     then do this } else if (this is true) {     then do this } else {     do this }
  • 27. 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
  • 28. 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;
  • 29. 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:*;
  • 30. Placement • An instance of a movie clip can be moved to any location using x and y as coordinates: myClip.x = 300; myClip.y = 200;
  • 31. Movement • An instance of a movie clip can be told to move by adding a value to x or y: // Setup the values var moveX:Number = 10; var moveY:Number = 10; // Move the clips myClip.x = myClip.x + moveX; myClip.y = myClip.y + moveY;
  • 32. 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);
  • 33. Homework, due Sept 23 • Read Chapter 1, p1-42 in the ActionScript 3.0 Cookbook