SlideShare a Scribd company logo
OO JS for AS3 Devs Object-Oriented JavaScript for ActionScript 3 Developers
Pirates vs Ninjas Pirate Ninja
JS vs AS3 Object Number String Boolean Object Object Array (Object)  Date Function Function Prototype <Script src=&quot;&quot;/> Function Object Number | int | unit String Boolean Array Dictionary Array Date Function Class Prototype Import Getter / Setter
No Strong Types in JS var myVar1; var myVar1 = 10; var myVar1, myVar2, myVar3; var myVar = []; myVar.push(&quot;foo&quot;); const EVENT_NAME = &quot;name&quot; var myVar:Object public myVar public function myFunct():String function myFunct():String package {}, class {}  extends, implements, final, internal, public, private GOOD PUPPY  BAD PUPPY 
'Classes' in JS     Everything is an Object or Function Functions are pushed to the limits A JS Class is just a Function Function 'scope' rules are used for to create public, private spaces Inheritance is wacky ( will get to this later ) Prototype is wacky ( will get to this later )  
function myClass() {      this.add = function(a, b)          {          return a + b;      }; } var c = new myClass(); c.add(1, 1); TEST IN FIREBUG
Getters / Setters function Puppy() {      var _evil = 1000;      this. getEvil  = function()      {          return _evil;      };      this. setEvil  = function(value)      {          _evil  = value;      } } var evilPuppy = new Puppy(); evilPuppy. getEvil() ;
Self Executing Functions function Puppy() {      var _evil = 999;      this.getEvil = function()      {          return _evil;      };      (function init(value)      {          _evil = v;      })(45) } var evilPuppy = new Puppy(); evilPuppy.getEvil();
Scope is a Pain! function level_1() {      var good = 20;      this.evil = 99;      var timeout = setTimeout(function()          {              console.log(good);              console.log(evil);              console.log(this.evil);          }, 500); } var x = new level_1();
Scope is a Pain - Part 2 function level_1() {      var good = 20;      this.evil = 99;      var scope = this;      var timeout = setTimeout(function()          {              console.log(good);              console.log(scope.evil);          }, 500); } var x = new level_1();
Inheritance Tons of ways to do Inheritance  I will only cover one way No &quot;extends&quot; in JS Completely different way of thinking about it Special property on Object named Prototype
function Animal() {      Animal.prototype.evil = 1000;      Animal.prototype.getColor = function()      {          return &quot;Blood Red&quot;;      } } function Puppy()  { } Puppy.prototype = Animal.prototype; var p = new Puppy(); p.getColor();
function Animal() {      Animal.prototype.evil = 1000;      Animal.prototype.getColor = function()      {          return &quot;Blood Red&quot;;      } } function Puppy()  { } new Animal(); //(GOTCHA!) Puppy.prototype = Animal.prototype; var p = new Puppy(); p.getColor();
function Animal(){      Animal.prototype.color = &quot;Blood Red&quot;;      Animal.prototype.getColor = function()      {          return &quot;Evil &quot; + this.color;      } }; var a = new Animal(); console.log(&quot;Animal Color: &quot; + a.getColor()); function Puppy() {      this.color = &quot;Blue&quot;; } Puppy.prototype = Animal.prototype; var p = new Puppy(); console.log(&quot;Puppy Color: &quot; + p.getColor());
HTML5 <canvas> tag  <body> <canvas id=&quot;gameCanvas&quot; width=&quot;600&quot; height=&quot;600&quot;></canvas> </body>
Get Pointer to <canvas> from JS // javaScript var canvas = document.getElementById('gameCanvas'); var context = canvas.getContext('2d');
Draw on <canvas> with JS // javaScript context.beginPath(); context.moveTo(0,0); context.lineTo(0,100); context.lineTo(100,100); context.lineTo(100,0); context.closePath(); context.strokeStyle = &quot;#000000&quot;; context.fill(); context.fillStyle = &quot;#CCCCCC&quot;; context.fill();
&quot;Animation&quot; (in quotes) var intervalId = setInterval(drawCanvas, 1000 / 30); function drawCanvas(){      // clear everything      context.clearRect(0,0, myWidth, myHeight);      // redraw everything      // Yes, you better know exactly       // where every pixel is at all times so       // you can redraw it at 30 FPS      // :( }
&quot;Animation&quot; (in quotes) var intervalId = setInterval(smartDrawCanvas, 1000 / 30); function smartDrawCanvas() {      // Clear only part of the canvas      context.clearRect(25, 25, 50, 50);      // redraw SOME of the canvas      // TODO .... }
Mouse Events on <canvas> Cannot listen to events on any children on the <canvas> Think of <canvas> as AS3 Bitmap You can only listen on the main <canvas> object You need to know where every 'interactive' object is the <canvas> at all times. For clicks you need to calculate what was under the pixel that was clicked on Observer pattern helps with this work
Gotchas **JS** (for each works in FF, but not Chrome) for (var x in myArray) {      var obj = myArray[x];      obj.selected = false; } **AS3** for each (var x:Object in myArray) {      x.selected = false; }
Gotchas var timeout = setTimeout(function()      {                  var x = passThruVar1;          // x is undefined!!!      }, 500,  passThruVar1 ,  passThruVar2 );
Ad

More Related Content

What's hot (20)

Intro to Pig UDF
Intro to Pig UDFIntro to Pig UDF
Intro to Pig UDF
Chris Wilkes
 
Advanced python
Advanced pythonAdvanced python
Advanced python
EU Edge
 
Docopt
DocoptDocopt
Docopt
René Ribaud
 
node ffi
node ffinode ffi
node ffi
偉格 高
 
Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the point
seanmcq
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
Sebastiano Armeli
 
XpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp wayXpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp way
Giordano Scalzo
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
Brian Moschel
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
Giordano Scalzo
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
Bryan Helmig
 
Stop Programming in JavaScript By Luck
Stop Programming in JavaScript By LuckStop Programming in JavaScript By Luck
Stop Programming in JavaScript By Luck
sergioafp
 
Javascript Function
Javascript FunctionJavascript Function
Javascript Function
xxbeta
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)
jeffz
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to Swift
Giordano Scalzo
 
Lecture05
Lecture05Lecture05
Lecture05
elearning_portal
 
The Evolution of Async-Programming on .NET Platform (TUP, Full)
The Evolution of Async-Programming on .NET Platform (TUP, Full)The Evolution of Async-Programming on .NET Platform (TUP, Full)
The Evolution of Async-Programming on .NET Platform (TUP, Full)
jeffz
 
A Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming LanguageA Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming Language
SmartLogic
 
Txjs
TxjsTxjs
Txjs
Peter Higgins
 
C++ tutorial
C++ tutorialC++ tutorial
C++ tutorial
sikkim manipal university
 
C++totural file
C++totural fileC++totural file
C++totural file
halaisumit
 
Advanced python
Advanced pythonAdvanced python
Advanced python
EU Edge
 
Gevent what's the point
Gevent what's the pointGevent what's the point
Gevent what's the point
seanmcq
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
Sebastiano Armeli
 
XpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp wayXpUg Coding Dojo: KataYahtzee in Ocp way
XpUg Coding Dojo: KataYahtzee in Ocp way
Giordano Scalzo
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
Brian Moschel
 
Agile Iphone Development
Agile Iphone DevelopmentAgile Iphone Development
Agile Iphone Development
Giordano Scalzo
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
Bryan Helmig
 
Stop Programming in JavaScript By Luck
Stop Programming in JavaScript By LuckStop Programming in JavaScript By Luck
Stop Programming in JavaScript By Luck
sergioafp
 
Javascript Function
Javascript FunctionJavascript Function
Javascript Function
xxbeta
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)
jeffz
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to Swift
Giordano Scalzo
 
The Evolution of Async-Programming on .NET Platform (TUP, Full)
The Evolution of Async-Programming on .NET Platform (TUP, Full)The Evolution of Async-Programming on .NET Platform (TUP, Full)
The Evolution of Async-Programming on .NET Platform (TUP, Full)
jeffz
 
A Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming LanguageA Few Interesting Things in Apple's Swift Programming Language
A Few Interesting Things in Apple's Swift Programming Language
SmartLogic
 
C++totural file
C++totural fileC++totural file
C++totural file
halaisumit
 

Similar to OO JS for AS3 Devs (20)

Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
LearningTech
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
Dmitry Baranovskiy
 
Say It With Javascript
Say It With JavascriptSay It With Javascript
Say It With Javascript
Giovanni Scerra ☃
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
whitneyleman54422
 
Web Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for PerformanceWeb Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for Performance
johndaviddalton
 
04 Advanced Javascript
04 Advanced Javascript04 Advanced Javascript
04 Advanced Javascript
crgwbr
 
An Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End DevelopersAn Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End Developers
FITC
 
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
Haris Mahmood
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
kvangork
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
kvangork
 
Javascript Primer
Javascript PrimerJavascript Primer
Javascript Primer
Adam Hepton
 
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)
jeresig
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchained
Eduard Tomàs
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
Stoyan Stefanov
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
Julie Iskander
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
Anders Jönsson
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
Christian Baranowski
 
Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.
Alberto Naranjo
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
Stoyan Stefanov
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
Colin DeCarlo
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
LearningTech
 
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docxsrcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
srcArtifact.javasrcArtifact.javaclassArtifactextendsCave{pub.docx
whitneyleman54422
 
Web Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for PerformanceWeb Optimization Summit: Coding for Performance
Web Optimization Summit: Coding for Performance
johndaviddalton
 
04 Advanced Javascript
04 Advanced Javascript04 Advanced Javascript
04 Advanced Javascript
crgwbr
 
An Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End DevelopersAn Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End Developers
FITC
 
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
Haris Mahmood
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
kvangork
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
kvangork
 
Javascript Primer
Javascript PrimerJavascript Primer
Javascript Primer
Adam Hepton
 
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)
jeresig
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchained
Eduard Tomàs
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
Stoyan Stefanov
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
Julie Iskander
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
Anders Jönsson
 
Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.Javascript quiz. Questions to ask when recruiting developers.
Javascript quiz. Questions to ask when recruiting developers.
Alberto Naranjo
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
Colin DeCarlo
 
Ad

More from Jason Hanson (6)

HelloGit
HelloGitHelloGit
HelloGit
Jason Hanson
 
Reinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine stepsReinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine steps
Jason Hanson
 
Mobile Flex - Flash Camp St. Louis
Mobile Flex - Flash Camp St. LouisMobile Flex - Flash Camp St. Louis
Mobile Flex - Flash Camp St. Louis
Jason Hanson
 
Maximizing Code Reuse Across Screens
Maximizing Code Reuse Across ScreensMaximizing Code Reuse Across Screens
Maximizing Code Reuse Across Screens
Jason Hanson
 
Deep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item RenderersDeep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item Renderers
Jason Hanson
 
Burrito and Hero
Burrito and HeroBurrito and Hero
Burrito and Hero
Jason Hanson
 
Reinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine stepsReinvent yourself - How to become a native iOS developer in nine steps
Reinvent yourself - How to become a native iOS developer in nine steps
Jason Hanson
 
Mobile Flex - Flash Camp St. Louis
Mobile Flex - Flash Camp St. LouisMobile Flex - Flash Camp St. Louis
Mobile Flex - Flash Camp St. Louis
Jason Hanson
 
Maximizing Code Reuse Across Screens
Maximizing Code Reuse Across ScreensMaximizing Code Reuse Across Screens
Maximizing Code Reuse Across Screens
Jason Hanson
 
Deep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item RenderersDeep Dive into Flex Mobile Item Renderers
Deep Dive into Flex Mobile Item Renderers
Jason Hanson
 
Ad

Recently uploaded (20)

Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Cybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure ADCybersecurity Identity and Access Solutions using Azure AD
Cybersecurity Identity and Access Solutions using Azure AD
VICTOR MAESTRE RAMIREZ
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Unlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive GuideUnlocking the Power of IVR: A Comprehensive Guide
Unlocking the Power of IVR: A Comprehensive Guide
vikasascentbpo
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 

OO JS for AS3 Devs

  • 1. OO JS for AS3 Devs Object-Oriented JavaScript for ActionScript 3 Developers
  • 2. Pirates vs Ninjas Pirate Ninja
  • 3. JS vs AS3 Object Number String Boolean Object Object Array (Object)  Date Function Function Prototype <Script src=&quot;&quot;/> Function Object Number | int | unit String Boolean Array Dictionary Array Date Function Class Prototype Import Getter / Setter
  • 4. No Strong Types in JS var myVar1; var myVar1 = 10; var myVar1, myVar2, myVar3; var myVar = []; myVar.push(&quot;foo&quot;); const EVENT_NAME = &quot;name&quot; var myVar:Object public myVar public function myFunct():String function myFunct():String package {}, class {}  extends, implements, final, internal, public, private GOOD PUPPY  BAD PUPPY 
  • 5. 'Classes' in JS     Everything is an Object or Function Functions are pushed to the limits A JS Class is just a Function Function 'scope' rules are used for to create public, private spaces Inheritance is wacky ( will get to this later ) Prototype is wacky ( will get to this later )  
  • 6. function myClass() {      this.add = function(a, b)          {          return a + b;      }; } var c = new myClass(); c.add(1, 1); TEST IN FIREBUG
  • 7. Getters / Setters function Puppy() {      var _evil = 1000;      this. getEvil = function()      {          return _evil;      };      this. setEvil = function(value)      {          _evil  = value;      } } var evilPuppy = new Puppy(); evilPuppy. getEvil() ;
  • 8. Self Executing Functions function Puppy() {      var _evil = 999;      this.getEvil = function()      {          return _evil;      };      (function init(value)      {          _evil = v;      })(45) } var evilPuppy = new Puppy(); evilPuppy.getEvil();
  • 9. Scope is a Pain! function level_1() {      var good = 20;      this.evil = 99;      var timeout = setTimeout(function()          {              console.log(good);              console.log(evil);              console.log(this.evil);          }, 500); } var x = new level_1();
  • 10. Scope is a Pain - Part 2 function level_1() {      var good = 20;      this.evil = 99;      var scope = this;      var timeout = setTimeout(function()          {              console.log(good);              console.log(scope.evil);          }, 500); } var x = new level_1();
  • 11. Inheritance Tons of ways to do Inheritance  I will only cover one way No &quot;extends&quot; in JS Completely different way of thinking about it Special property on Object named Prototype
  • 12. function Animal() {      Animal.prototype.evil = 1000;      Animal.prototype.getColor = function()      {          return &quot;Blood Red&quot;;      } } function Puppy()  { } Puppy.prototype = Animal.prototype; var p = new Puppy(); p.getColor();
  • 13. function Animal() {      Animal.prototype.evil = 1000;      Animal.prototype.getColor = function()      {          return &quot;Blood Red&quot;;      } } function Puppy()  { } new Animal(); //(GOTCHA!) Puppy.prototype = Animal.prototype; var p = new Puppy(); p.getColor();
  • 14. function Animal(){      Animal.prototype.color = &quot;Blood Red&quot;;      Animal.prototype.getColor = function()      {          return &quot;Evil &quot; + this.color;      } }; var a = new Animal(); console.log(&quot;Animal Color: &quot; + a.getColor()); function Puppy() {      this.color = &quot;Blue&quot;; } Puppy.prototype = Animal.prototype; var p = new Puppy(); console.log(&quot;Puppy Color: &quot; + p.getColor());
  • 15. HTML5 <canvas> tag  <body> <canvas id=&quot;gameCanvas&quot; width=&quot;600&quot; height=&quot;600&quot;></canvas> </body>
  • 16. Get Pointer to <canvas> from JS // javaScript var canvas = document.getElementById('gameCanvas'); var context = canvas.getContext('2d');
  • 17. Draw on <canvas> with JS // javaScript context.beginPath(); context.moveTo(0,0); context.lineTo(0,100); context.lineTo(100,100); context.lineTo(100,0); context.closePath(); context.strokeStyle = &quot;#000000&quot;; context.fill(); context.fillStyle = &quot;#CCCCCC&quot;; context.fill();
  • 18. &quot;Animation&quot; (in quotes) var intervalId = setInterval(drawCanvas, 1000 / 30); function drawCanvas(){      // clear everything      context.clearRect(0,0, myWidth, myHeight);      // redraw everything      // Yes, you better know exactly       // where every pixel is at all times so       // you can redraw it at 30 FPS      // :( }
  • 19. &quot;Animation&quot; (in quotes) var intervalId = setInterval(smartDrawCanvas, 1000 / 30); function smartDrawCanvas() {      // Clear only part of the canvas      context.clearRect(25, 25, 50, 50);      // redraw SOME of the canvas      // TODO .... }
  • 20. Mouse Events on <canvas> Cannot listen to events on any children on the <canvas> Think of <canvas> as AS3 Bitmap You can only listen on the main <canvas> object You need to know where every 'interactive' object is the <canvas> at all times. For clicks you need to calculate what was under the pixel that was clicked on Observer pattern helps with this work
  • 21. Gotchas **JS** (for each works in FF, but not Chrome) for (var x in myArray) {      var obj = myArray[x];      obj.selected = false; } **AS3** for each (var x:Object in myArray) {      x.selected = false; }
  • 22. Gotchas var timeout = setTimeout(function()      {                  var x = passThruVar1;          // x is undefined!!!      }, 500, passThruVar1 , passThruVar2 );

Editor's Notes

  • #7: function myClass() {      this.add = function(a, b)          {          return a + b;      }; } var c = new