SlideShare uma empresa Scribd logo
1 de 33
Baixar para ler offline
Creative Programming in ActionScript 3.0
•   Flash Platform Consultant
•   Lecturer Devine
•   Adobe Community Expert
•   Technical author
•   Full time web geek
Creativity is a mental process involving
the generation of new ideas or concepts,
or new associations of the creative mind
  between existing ideas or concepts.
Programming is a the process of writing,
 testing, debugging and maintaining the
  source code of computer programs.
What will we talk about?
•   Object-Oriented Programming
    • Classes and instances
    • Inheritance
    • Encapsulation
•   Basic trigonometry
    • Distance between points
    • Polar and Cartesian coordinates
•   Experimentation
    • BitmapData
    • Sound Spectrum
Object-Oriented Programming
Classes and instances
Classes
•   Classes are blueprints of functionality
•   Allow for reusable and modular code
•   Contain methods (functions) and properties (variables)




                 Ball class
Instances
•   Instances (objects) are copies based on a class blueprint
•   Instance property values are independent of its class




                              Ball class




Ball instance         Ball instance           Ball instance
Example (Library panel)
HelloWorld.as

package {

    public class HelloWorld {

        public var name:String;

        public function HelloWorld(value:String) {
          this.name = value;
          trace(“Hello world from “+ this.name);
        }

    }

}
HelloWorld instances

var myWorld:HelloWorld = new HelloWorld(“Peter”);
// Hello world from Peter
trace(myWorld.name); // Peter


var otherWorld:HelloWorld = new HelloWorld(“Barack”);
// Hello world from Barack
trace(myWorld.name); // Barack
Inheritance
•   Classes can extend each others functionality
•   Each class can only inherit from one super class
•   Use the “extends” keyword


                  Animal class

       Dog class                     Cat class

                                    Tiger class
Example (inheritance.fla)
Encapsulation
•   Protect the inner workings of your class
•   Access modifiers (public, private, protected, internal)
•   Use getter/setter methods to provide access




         getter/setter
                                     other class
         class
       internals
Access modifiers
•   public - accessible from anywhere
•   private - only accessible from within the class
•   protected - only accessible within class and subclasses
•   internal - only accessible within same package (default)
Getter/setters
•   Looks like a method, behaves like a property
•   Provides a single entry point for setting a property
•   Useful for input validation

    private var _age:Number;

    public function get age():Number {
      return this._age;
    }

    public function set age(val:Number):void {
      if(val >= 18) {
        this._age = val;
      } else {
        trace(“you are too young”);
      }
    }
Account.as
package {
  public class Account {
    private var _email:String;

        public function set email(val:String):void {
          if(val.indexOf(“@”) != -1) {
            this._email = val;
          } else {
            trace(“invalid email”);
          }
        }

    }
}

var myAccount:Account = new Account();
myAccount.email = “peter.elst@gmail.com”;
Basic Trigonometry
Distance between points

                point 2




 point 1
Distance between points

                   point 2


           C
                       B


 point 1
               A
A² + B² = C²
√
d(P1,
P2)
=



(x2
‐
x1)2
+
(y 
–
y )
2
                              2    1
Example (distance.fla)
Cartesian coordinates

                 (x,y)




                         x




           y
Polar coordinates

               (r, θ)

           r

           θ
A² + B² = C²

                (r, θ)

        C
                B
        θ

            A
Converting polar coordinates

     x
=
Math.cos(θ)
*
radius
     y
=
Math.sin(θ)
*
radius


    θ
is
the
angle
in
radians
Example (polar-animation.fla)
Experimentation
flash.display.BitmapData

 •   Allows you to get pixel level access to bitmaps
 •   Work with color channels
 •   Perform bitmap operations
SoundMixer.computeSpectrum

•   Returns spectrum information of sound
•   ByteArray with floating point values between -1 and 1
•   Raw wave form or Fast Fourier Transform (FFT)
•   Doesn’t work for microphone input (yet) :(
    • see www.getmicrophone.com
Books
Foundation ActionScript 3.0 Animation “Making Things Move”
Object-Oriented ActionScript 3.0

Websites
www.gotoandlearn.com
www.levitated.net



Get in touch
Email: peter.elst@gmail.com
Blog: www.peterelst.com
Twitter: peterelst




                                                             Thank you!

Mais conteúdo relacionado

Mais procurados (9)

ECCV2010: feature learning for image classification, part 2
ECCV2010: feature learning for image classification, part 2ECCV2010: feature learning for image classification, part 2
ECCV2010: feature learning for image classification, part 2
 
C h 04 oop_inheritance
C h 04 oop_inheritanceC h 04 oop_inheritance
C h 04 oop_inheritance
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)
 
Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Functional programming in Scala
Functional programming in ScalaFunctional programming in Scala
Functional programming in Scala
 
Authorship attribution pydata london
Authorship attribution   pydata londonAuthorship attribution   pydata london
Authorship attribution pydata london
 
Ch2 Liang
Ch2 LiangCh2 Liang
Ch2 Liang
 
Propof identequal.ppt
Propof identequal.pptPropof identequal.ppt
Propof identequal.ppt
 

Destaque

Object-Oriented ActionScript 3.0
Object-Oriented ActionScript 3.0Object-Oriented ActionScript 3.0
Object-Oriented ActionScript 3.0
Peter Elst
 
How to build an AOP framework in ActionScript
How to build an AOP framework in ActionScriptHow to build an AOP framework in ActionScript
How to build an AOP framework in ActionScript
Christophe Herreman
 
Essential action script 3.0
Essential action script 3.0Essential action script 3.0
Essential action script 3.0
UltimateCodeX
 
Action script for designers
Action script for designersAction script for designers
Action script for designers
oyunbaga
 
Actionscript
ActionscriptActionscript
Actionscript
edinson
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
Saurabh Narula
 
Actionscript
ActionscriptActionscript
Actionscript
saysam
 
Historia de flas h, actionscript,director
Historia de flas h, actionscript,directorHistoria de flas h, actionscript,director
Historia de flas h, actionscript,director
diana-16ramos
 
Actionscript
ActionscriptActionscript
Actionscript
yyurany
 
Kernel vm#9 powerkvm-dist-20131208
Kernel vm#9 powerkvm-dist-20131208Kernel vm#9 powerkvm-dist-20131208
Kernel vm#9 powerkvm-dist-20131208
Manabu Ori
 

Destaque (20)

Coding Flash : ActionScript(3.0) Tutorial
Coding Flash :  ActionScript(3.0) TutorialCoding Flash :  ActionScript(3.0) Tutorial
Coding Flash : ActionScript(3.0) Tutorial
 
Object-Oriented ActionScript 3.0
Object-Oriented ActionScript 3.0Object-Oriented ActionScript 3.0
Object-Oriented ActionScript 3.0
 
How to build an AOP framework in ActionScript
How to build an AOP framework in ActionScriptHow to build an AOP framework in ActionScript
How to build an AOP framework in ActionScript
 
Giáo trình học Html5/Css3
Giáo trình học Html5/Css3Giáo trình học Html5/Css3
Giáo trình học Html5/Css3
 
Presentacion dreamweaver html
Presentacion dreamweaver htmlPresentacion dreamweaver html
Presentacion dreamweaver html
 
Cariño Especial
Cariño EspecialCariño Especial
Cariño Especial
 
Essential action script 3.0
Essential action script 3.0Essential action script 3.0
Essential action script 3.0
 
Giáo trình Flash CS5 và Action Script 3.0
Giáo trình Flash CS5 và Action Script 3.0Giáo trình Flash CS5 và Action Script 3.0
Giáo trình Flash CS5 và Action Script 3.0
 
Action script for designers
Action script for designersAction script for designers
Action script for designers
 
Actionscript
ActionscriptActionscript
Actionscript
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
 
Actionscript
ActionscriptActionscript
Actionscript
 
Historia de flas h, actionscript,director
Historia de flas h, actionscript,directorHistoria de flas h, actionscript,director
Historia de flas h, actionscript,director
 
Actionscript
ActionscriptActionscript
Actionscript
 
Kernel vm#9 powerkvm-dist-20131208
Kernel vm#9 powerkvm-dist-20131208Kernel vm#9 powerkvm-dist-20131208
Kernel vm#9 powerkvm-dist-20131208
 
Giáo trình đọc hiểu bản vẽ cơ khí
Giáo trình đọc hiểu bản vẽ cơ khíGiáo trình đọc hiểu bản vẽ cơ khí
Giáo trình đọc hiểu bản vẽ cơ khí
 
Giáo trình học tiếng anh Student book 1
Giáo trình học tiếng anh Student book 1Giáo trình học tiếng anh Student book 1
Giáo trình học tiếng anh Student book 1
 
Giáo trình giảng dạy Autocad 2016 cơ bản
Giáo trình giảng dạy Autocad 2016 cơ bảnGiáo trình giảng dạy Autocad 2016 cơ bản
Giáo trình giảng dạy Autocad 2016 cơ bản
 
Giáo trình Robot Structural 2016 Tập 2
Giáo trình Robot Structural 2016 Tập 2Giáo trình Robot Structural 2016 Tập 2
Giáo trình Robot Structural 2016 Tập 2
 
AppCodes - app store marketing toolbox
AppCodes - app store marketing toolboxAppCodes - app store marketing toolbox
AppCodes - app store marketing toolbox
 

Semelhante a Creative Programming in ActionScript 3.0

Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4
elliando dias
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Rails
elliando dias
 
javascript teach
javascript teachjavascript teach
javascript teach
guest3732fa
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_White
guest3732fa
 
A Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpA Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented Php
Michael Girouard
 
Implementation of interface9 cm604.30
Implementation of interface9 cm604.30Implementation of interface9 cm604.30
Implementation of interface9 cm604.30
myrajendra
 
Metaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailsMetaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And Grails
zenMonkey
 

Semelhante a Creative Programming in ActionScript 3.0 (20)

JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)
 
Tamarin And Ecmascript 4
Tamarin And Ecmascript 4Tamarin And Ecmascript 4
Tamarin And Ecmascript 4
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Rails
 
javascript teach
javascript teachjavascript teach
javascript teach
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_White
 
What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?
 
Tamarin and ECMAScript 4
Tamarin and ECMAScript 4Tamarin and ECMAScript 4
Tamarin and ECMAScript 4
 
Dart
DartDart
Dart
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Groovy and Grails talk
Groovy and Grails talkGroovy and Grails talk
Groovy and Grails talk
 
A Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented PhpA Gentle Introduction To Object Oriented Php
A Gentle Introduction To Object Oriented Php
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
C# v8 new features - raimundas banevicius
C# v8 new features - raimundas baneviciusC# v8 new features - raimundas banevicius
C# v8 new features - raimundas banevicius
 
No JS and DartCon
No JS and DartConNo JS and DartCon
No JS and DartCon
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# Developers
 
Implementation of interface9 cm604.30
Implementation of interface9 cm604.30Implementation of interface9 cm604.30
Implementation of interface9 cm604.30
 
Metaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailsMetaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And Grails
 

Mais de Peter Elst

P2P with Flash Player 10.1
P2P with Flash Player 10.1P2P with Flash Player 10.1
P2P with Flash Player 10.1
Peter Elst
 
Big boys and their litl toys
Big boys and their litl toysBig boys and their litl toys
Big boys and their litl toys
Peter Elst
 
FATC - AIR 2.0 workshop
FATC - AIR 2.0 workshopFATC - AIR 2.0 workshop
FATC - AIR 2.0 workshop
Peter Elst
 
Introduction to AS3Signals
Introduction to AS3SignalsIntroduction to AS3Signals
Introduction to AS3Signals
Peter Elst
 
The Secret Life of a Flash Freelancer
The Secret Life of a Flash FreelancerThe Secret Life of a Flash Freelancer
The Secret Life of a Flash Freelancer
Peter Elst
 
Getting Creative with Adobe AIR
Getting Creative with Adobe AIRGetting Creative with Adobe AIR
Getting Creative with Adobe AIR
Peter Elst
 
Introduction to SQLite in Adobe AIR 1.5
Introduction to SQLite in Adobe AIR 1.5Introduction to SQLite in Adobe AIR 1.5
Introduction to SQLite in Adobe AIR 1.5
Peter Elst
 
RIA meets Desktop
RIA meets DesktopRIA meets Desktop
RIA meets Desktop
Peter Elst
 
The Evolution of the Flash Platform
The Evolution of the Flash PlatformThe Evolution of the Flash Platform
The Evolution of the Flash Platform
Peter Elst
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
Peter Elst
 

Mais de Peter Elst (17)

P2P on the local network
P2P on the local networkP2P on the local network
P2P on the local network
 
P2P with Flash Player 10.1
P2P with Flash Player 10.1P2P with Flash Player 10.1
P2P with Flash Player 10.1
 
Big boys and their litl toys
Big boys and their litl toysBig boys and their litl toys
Big boys and their litl toys
 
Yes, you can do that with AIR 2.0
Yes, you can do that with AIR 2.0Yes, you can do that with AIR 2.0
Yes, you can do that with AIR 2.0
 
FATC - AIR 2.0 workshop
FATC - AIR 2.0 workshopFATC - AIR 2.0 workshop
FATC - AIR 2.0 workshop
 
Developing with Adobe AIR
Developing with Adobe AIRDeveloping with Adobe AIR
Developing with Adobe AIR
 
Introduction to AS3Signals
Introduction to AS3SignalsIntroduction to AS3Signals
Introduction to AS3Signals
 
The Secret Life of a Flash Freelancer
The Secret Life of a Flash FreelancerThe Secret Life of a Flash Freelancer
The Secret Life of a Flash Freelancer
 
Getting Creative with Adobe AIR
Getting Creative with Adobe AIRGetting Creative with Adobe AIR
Getting Creative with Adobe AIR
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
 
Introduction to SQLite in Adobe AIR 1.5
Introduction to SQLite in Adobe AIR 1.5Introduction to SQLite in Adobe AIR 1.5
Introduction to SQLite in Adobe AIR 1.5
 
RIA meets Desktop
RIA meets DesktopRIA meets Desktop
RIA meets Desktop
 
The Evolution of the Flash Platform
The Evolution of the Flash PlatformThe Evolution of the Flash Platform
The Evolution of the Flash Platform
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
 
Introduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIRIntroduction to SQLite in Adobe AIR
Introduction to SQLite in Adobe AIR
 
RIA meets Desktop
RIA meets DesktopRIA meets Desktop
RIA meets Desktop
 
SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0
SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0
SkillsMatter - In-the-Brain session - What's new in ActionScript 3.0
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+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@
 

Último (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
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
 
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...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+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...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Creative Programming in ActionScript 3.0

  • 1. Creative Programming in ActionScript 3.0
  • 2. Flash Platform Consultant • Lecturer Devine • Adobe Community Expert • Technical author • Full time web geek
  • 3. Creativity is a mental process involving the generation of new ideas or concepts, or new associations of the creative mind between existing ideas or concepts.
  • 4. Programming is a the process of writing, testing, debugging and maintaining the source code of computer programs.
  • 5. What will we talk about? • Object-Oriented Programming • Classes and instances • Inheritance • Encapsulation • Basic trigonometry • Distance between points • Polar and Cartesian coordinates • Experimentation • BitmapData • Sound Spectrum
  • 8. Classes • Classes are blueprints of functionality • Allow for reusable and modular code • Contain methods (functions) and properties (variables) Ball class
  • 9. Instances • Instances (objects) are copies based on a class blueprint • Instance property values are independent of its class Ball class Ball instance Ball instance Ball instance
  • 11. HelloWorld.as package { public class HelloWorld { public var name:String; public function HelloWorld(value:String) { this.name = value; trace(“Hello world from “+ this.name); } } }
  • 12. HelloWorld instances var myWorld:HelloWorld = new HelloWorld(“Peter”); // Hello world from Peter trace(myWorld.name); // Peter var otherWorld:HelloWorld = new HelloWorld(“Barack”); // Hello world from Barack trace(myWorld.name); // Barack
  • 13. Inheritance • Classes can extend each others functionality • Each class can only inherit from one super class • Use the “extends” keyword Animal class Dog class Cat class Tiger class
  • 15. Encapsulation • Protect the inner workings of your class • Access modifiers (public, private, protected, internal) • Use getter/setter methods to provide access getter/setter other class class internals
  • 16. Access modifiers • public - accessible from anywhere • private - only accessible from within the class • protected - only accessible within class and subclasses • internal - only accessible within same package (default)
  • 17. Getter/setters • Looks like a method, behaves like a property • Provides a single entry point for setting a property • Useful for input validation private var _age:Number; public function get age():Number { return this._age; } public function set age(val:Number):void { if(val >= 18) { this._age = val; } else { trace(“you are too young”); } }
  • 18. Account.as package { public class Account { private var _email:String; public function set email(val:String):void { if(val.indexOf(“@”) != -1) { this._email = val; } else { trace(“invalid email”); } } } } var myAccount:Account = new Account(); myAccount.email = “peter.elst@gmail.com”;
  • 20. Distance between points point 2 point 1
  • 21. Distance between points point 2 C B point 1 A
  • 22. A² + B² = C²
  • 26. Polar coordinates (r, θ) r θ
  • 27. A² + B² = C² (r, θ) C B θ A
  • 28. Converting polar coordinates x
=
Math.cos(θ)
*
radius y
=
Math.sin(θ)
*
radius θ
is
the
angle
in
radians
  • 31. flash.display.BitmapData • Allows you to get pixel level access to bitmaps • Work with color channels • Perform bitmap operations
  • 32. SoundMixer.computeSpectrum • Returns spectrum information of sound • ByteArray with floating point values between -1 and 1 • Raw wave form or Fast Fourier Transform (FFT) • Doesn’t work for microphone input (yet) :( • see www.getmicrophone.com
  • 33. Books Foundation ActionScript 3.0 Animation “Making Things Move” Object-Oriented ActionScript 3.0 Websites www.gotoandlearn.com www.levitated.net Get in touch Email: peter.elst@gmail.com Blog: www.peterelst.com Twitter: peterelst Thank you!