SlideShare une entreprise Scribd logo
1  sur  149
ActionScript 3.0 Fundamentals Saurabh Narula http://blog.saurabhnarula.com/
Discussion Areas ,[object Object],[object Object],[object Object],[object Object],[object Object]
ActionScript  is the programming language for Adobe Flash Platform.
Language  specification  is open source Open Source  Compiler  – as part of Flex SDK Open source  Virtual Machine  – Mozilla Tamarin
Whats not open source .. Flash Player AIR
Initially designed for controlling simple 2D vector animations, few interactivity features (may be that’s why its  single threaded )
ActionScript executes in  ActionScript Virtual Machine  (AVM) A new ActionScript Virtual Machine, called  AVM2  – significant performance improvements over older AVM
Before we get going on ActionScript fundamentals .. Lets have a brief look and understand what is a  virtual machine  ..
Virtual Machine  is essentially a virtual environment/OS running within a actual/host operating systems.
In case of  AVM , we talk about  Process (Application)  Virtual Machines and not  System (Platform)  Virtual Machines.
Process VMs  provide a platform-independent programming environment that abstracts details of the underlying hardware or OS. Allows program to execute the same way on all platforms.
Process VM  provide high level abstraction, for a high level programming language.  This is done using an  interpreter
Programmer writes code in high level/human readable form which a machine can not understand .. so this source code has to be converted into machine code, this conversion is performed by  Interpreter.
Compiler  makes the conversion once. Interpreter  converts it every time a program is executed.
Just in time Compilation  (JIT) – offers improved runtime performance than interpreter.
Interpreter  interpret the byte code or sometimes interpret source code directly without having a byte code. These techniques offer lower performance.
In case of JIT, a compiler can be used during execution –  dynamic compilation . Remember – compilation from byte code to machine code is much faster than compiling from source.
AVM2  takes ActionScript bytecode ABC file as an input.
AVM2 Architecture
GC  in flash player does not work constantly, only triggered by allocations.
GC  in flash player is iterative, doesn’t guarantee to find all collectible blocks in one pass.
GC works  by  starting at the top of the object trees – Stage, ApplicationDomain/Class Definitions, Stack/Local Variables  Mark the object and any objects they reference. Go through the heap and free anything that isn't marked.
ActionScript is based on  ECMAScript
Event model based on the Document Object Model ( DOM ) Level 3 Events Specification
DOM  is a convention for representing and interacting with objects in HTML, XML type documents.
Variables  consists of 3 different parts – name, type of the data, actual value in computer’s memory
Constant  is same as variable but can be assigned only once.
Using  constants  than a literal value makes code more readable. Change the value at one place than having it changed everywhere if using a hard-coded literal value. For example INTREST_RATE
Data types Fundamental  – single value like string, number, int, boolean etc .. Complex  – set of values like Date.
Creating  objects  is a way of organizing your code. In OOP related information and functionality is grouped together in form of objects.
Class  is a template or a blueprint of how object should look like, basis of the object creation.
A Class can have  Properties, Methods, Events.
Property  is data/information bundled within the object.
To access a property you use  “variable name-dot-property name”  structure.
A  Method  is an operation that object can perform, are not value placeholders.
Event  is essentially an event that happens which ActionScript is aware of and can respond to.
Event Handling  is an action that you perform in response to a particular event.
Three important elements of  Event handling  – even source, event, response.
function  eventResponse(eventObject:EventType ):void { // Actions performed in response to the event go here. } eventSource .addEventListener( EventType.EVENT_NAME , eventResponse);
Event handling - Compiler makes note of all the eventResponse() functions. Event source keeps a list of functions that are listening to each of its events. When the event happens, object is created for that event’s class and passes it on to eventResponse function.
You directly  instantiate  a visual object by using it in MXML.  For non visual objects you can  instantiate  them by using  new operator  or by assigning a  literal value . Both approaches are same with a difference of calling base class constructor when using the new operator.
You can  build Flash applications using ActionScript 3.0  without using Flex SDK (create AS only project in Flash Builder), you can add AS code to frames in a timeline in Flash Professional.
You can choose to Embed code in MXML files inside <fx:script> tag, alternatively you can import ActionScript code from an external file and specify the source attribute of the <fx:script> tag. You can also import the  unstructured   code  using the include statement.
Include an  ActionScript Class  using import statement.
Flash Builder  can be used to create apps using Flex SDK, and ActionScript only projects.
You use  Flash Professional  when you want to create your visual assets (graphics, interactivities etc) and work with timeline/frames and write code in the same application.
Other third party tools  – FDT, TextMate (with AS, Flex bundles) etc.
Class Design Considerations .. A  class  can be type value object, display object, supporting class.
Class Design Considerations .. Your  class  can dispatch events if other parts of application need to know of some change.
Class Design Considerations .. Consider creating a subclass if a  class  exists with a similar functionality.
Lets take a detailed look at ActionScript 3.0 language and syntax.
Objects and Classes .. All classes, built in or user defined derive from Object class.
Objects and Classes .. var obj:*; //untyped object  key differentiator – can hold undefined value, variable of type object cannot hold undefined.
Packages and namespaces .. Related concepts but not same.
Packages .. Implemented using namespaces (we will see later ..)
Packages .. You can have variables, function, statements at the top level (and not just classes) but can only be public or internal.
Packages .. Doesn’t support private classes
Packages .. Main benefit – helps in avoiding name conflicts
Packages .. Import statements should be as specific as possible. Import TestPackage.*; //avoid this – may lead to unexpected name conflicts. Import TestPackage.SomeClass;
Packages .. Default access specifier for all members of package is internal.
Packages .. Resolving name conflicts – import samples.SampleCode; import langref.samples.SampleCode; var mySample:SampleCode = new SampleCode(); // name conflict //use fully qualified names to resolve name conflicts var sample1:samples.SampleCode = new samples.SampleCode(); var sample2:langref.samples.SampleCode = new langref.samples.SampleCode();
Namespaces .. Create your own namespace to define your own access control specifier.
Namespaces .. You can attach a URI to the namespace definition, this makes sure that the definition is unique.  If URI is not defined, compiler creates a unique identifier string in place of URI.
Namespaces .. Cannot redefine a namespace in a same scope.
Namespaces .. Can apply only one namespace to each declaration.
Namespaces .. If you apply a namespace, you cannot also apply access control specifier.
Packages are abstractions built on top of namespaces.
mx_internal identifier used in Flex SDK
Variable Scope .. There is no block level scope, interesting implication of this is that you can read or write variable before it is declared.
Data Types .. Primitive type (boolean, int, number, string, uint)  objects are stored as immutable objects, which means passing by reference is same as passing by value. Immutable objects  - When you have a reference to an instance of object, the content of the instance can not be altered. Complex types/values are passed as reference.
Type Checking .. Can occur at both compile and runtime.
Type Checking .. You can set compiler to run in  strict mode  – type checking at both compile time and runtime  or  standard mode  – only at runtime
Type Checking .. Compile time checking is favored in case of large projects, catching type errors as early as possible is important.
Type Checking ..  when you use untyped object, you are not eliminating type checking but deferring it to the runtime.
Type Checking .. Upcast – Use base class to declare the type of a class instance but use a subclass to instantiate it.
is operator .. 1.  Checks if the object is an instance of a particular class,  2.  checks the inheritance hierarchy,  3.  and if an object is an instance of a class that implements a particular interface.
as operator .. Returns the value of the expression instead. Helps in ensuring that you are using a correct type.
Dynamic classes .. Can attach properties and methods outside the class definition.
Dynamic classes .. Type checking on dynamic properties is done at the runtime. Methods attached dynamically do not have access to private properties References to public properties or methods should be qualified with this or class name.
Data Types .. Primitive  – Boolean, int, Null, Number, String, Uint, void Complex  – Object, Array, Date, Error, Function,
Type Conversions .. Type conversions can be either implicit (coercion) or explicit (casting). Implicit conversions usually happen at the run time.
Implicit Conversions .. Can happen at runtime – in assignment statements, when values passed as function arguments, when values are returned from functions, when using + operator
Implicit Conversions .. For  user-defined types , implicit conversions succeed when the value to be converted is an instance of the destination class or a class that derives from the destination class
Implicit Conversions .. For  primitive types , implicit conversion happens the same way as in case of explicit conversion.
Explicit Conversions .. Good for type safety, will save you from any type conversion errors that might happen at the runtime.
Casting to int, uint, Number .. Can cast any data type to one of these, if the conversion fails then default value 0 for int & uint is assigned and Nan for Number.
Casting to Boolean .. Casting to Boolean from numeric types results in false if the numeric value is 0 and true otherwise.
Casting to String .. From any numeric types .. Returns a string representation of number, in case of arrays ..a comma delimited string of all array elements would be returned.
ActionScript syntax .. ActionScript is case sensitive.
ActionScript syntax ..  dot operator, literals, semicolons, parentheses, comments, keywords, reserve words, constants.
Operators, Operator precedence and associatively ..
Primary Operators .. Used for initializing array, object, group expression, calling a constructor etc.  For eample [], {x:y}, (), new resp.
Other Operators .. Postfix, Unary, multiplicative, additive, bitwise shift, relational, equality, bitwise logical, logical, conditional, assignment.
Conditional Statements .. If, if .. else if, switch,
Looping .. for, for .. In, for each .. In, while, do .. while
Functions .. function statements vs. function expressions
Function statements .. Less verbose, less confusing.
Function Expressions .. Common use is that they are used only once and then discarded.
Difference between function expression & function statement .. In case of dynamic classes/objects, delete has no effect on function statements
Difference between function expression & function statement .. Can call function statement even before they are defined, not in case of fn expressions
Functions .. return statement terminates the function, any statement after return is not executed.
Nested functions .. Only available within its parent function unless a reference to the function is passed to outside code (function closures).
Function parameters .. All arguments are passed by reference except primitive types.
Functions parameters .. Number of arguments sent to a function can exceed the number of parameters defined for that function.
Default parameters .. Is similar to making a parameter as optional, a parameter with no default value becomes a required parameter. All parameters with default values should ideally be placed in the end of parameter list in function signature.
The arguments object .. Arguments is an array that includes all parameters passed to a function, argument.callee provides a reference to a function itself, which is useful for recursive calls (in function expressions).
.. (rest) parameter  specify array parameter that would allow you to accept any number of comma delimited parameters. Use of this makes arguments array unavailable.
.. (rest) parameter  can be used with other parameters, but should be the last parameter.
Function as Objects .. Function passed as arguments to another function are passed as reference.
Functions as objects .. Functions can have properties, methods like an object. It even has a read only property called length which stores the number of parameters defined for that function.
Function scope .. Same scope rules that apply to variables, apply to functions.
Scope Chain .. At the time of execution a  activation  object gets created that stores parameters and local variables, functions declared in the function body. We can not access  activation  object.
Scope chain .. Scope chain is created that contains the ordered list of objects, against which the identifier declarations (variables) are checked.
Scope chain .. Every function that executes has a scope chain, this is stored in an internal property. For example, for a nested function the scope chain starts with its own activation object, followed by its parent function’s activation object, until it reaches to global object. The global object is created when the ActionScript program begins, contains all global variables and functions.
Function closures .. Object that contains a snapshot of a function and its lexical environment.
Function closures .. Function closures retain the scope in which they were defined.
Object Oriented Programming in ActionScript
Classes abstract representation of object, usefulness of such an abstraction is apparent in big projects.
Class attributes .. Dynamic – allow properties (classes and properties) to be added at runtime. Final – can not extend the class. Internal – visible only inside the current package. Public – visible everywhere
Classes .. Can have a static property and instance property with the same name in the same class.
Classes .. You can have statements in the class definition, which would execute only once.
Class property attributes .. Internal, private, protected, public, static, User defined namespaces.
Private variable .. In case of dynamic classes, accessing a private variable returns undefined instead of an error.
Private variables .. Trying to access a private variable in strict mode using  dot operator  will generate a compile time error, and undefined in case of accessing using  [] bracket .  In standard mode, both cases will return undefined.
Static .. Can be used with var, const, function. Attach property to class rather than to instance of the class.
Static .. Static properties are part of a subclass’s scope chain, within a subclass a static variable or method can be used without referencing its class name.
Variable .. Can be declared using var and const keyword.
Variable ..  variable declared as both const and static must be initialized at the same time as you declare it.
Instance variables .. Cannot override var/const directly, can override setters/getters though.
Constructor methods .. Can only be public, doesn’t return any value.
Constructor methods .. Can explicitly call the super class constructor by using super(), compiler calls it if not explicitly called.
Constructor methods .. When using super statement with super(), always call super() first.
Static methods .. Does not affect a specific instance of a class, you can use  this  or  super  within the body of the static method. Not inherited but are in scope.
Instance methods .. Redefine an inherited method, final attribute is used to prevent subclasses from overriding a method.
Getters and setters .. Access class properties which are private as if you are accessing directly instead of calling a method. Avoids using names like getPropertyName(), setPropertyName()
Getters and setters .. Can use override attribute on getter and setter functions.
Bound methods .. Similar to function closure, this reference in a bound method remains bound to the instance that implements the method, whereas this reference is generic in case of function closure.
Enumerations .. Custom data types that you create to encapsulate small set of values.
Embedded asset classes .. [Embed] metadata tag, @Embed in MXML.
Interfaces .. Method declarations that allow unrelated objects to communicate with each other, i.e serves as a protocol.
Interfaces .. Any class that implements interface is responsible for defining the method implementations.
Interfaces .. Can not include variables or constants but can include getters and setters.
Interfaces .. Can be public or internal. Method definitions inside an interface can not have access specifiers. Interfaces can extend another interface.
Interfaces .. While implementing an interface, make sure number of parameters and the data type of each parameter is same, in case of default parameter not necessary to specify the same default values.
Inheritance .. Code reuse. Subclass is guaranteed to possess all the properties of its base class.
Inheritance .. Can take advantage of polymorphism by inheriting and overriding methods.
Inheritance .. Instance of a subclass can always be substituted for an instance of the base class.
Inheritance - Overriding methods Names of the parameters in the override method do not have to match the names of the parameters in the base class, as long as the number of parameters and the data type of each parameter matches.
Inheritance - Static Properties If an instance property is defined that uses the same name as a static property in the same class or a superclass, the instance property has higher precedence in the scope chain.

Contenu connexe

En vedette

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 ActionScriptChristophe Herreman
 
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/Css3Ho Ngoc Tan
 
Essential action script 3.0
Essential action script 3.0Essential action script 3.0
Essential action script 3.0UltimateCodeX
 
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.0Kenny Nguyen
 
Chapter 9 Interface
Chapter 9 InterfaceChapter 9 Interface
Chapter 9 InterfaceOUM SAOKOSAL
 
Action script for designers
Action script for designersAction script for designers
Action script for designersoyunbaga
 
Actionscript 3 - Session 2 Getting Started Flash IDE
Actionscript 3 - Session 2 Getting Started Flash IDEActionscript 3 - Session 2 Getting Started Flash IDE
Actionscript 3 - Session 2 Getting Started Flash IDEOUM SAOKOSAL
 
Action Script
Action ScriptAction Script
Action ScriptAngelin R
 
Creative Programming in ActionScript 3.0
Creative Programming in ActionScript 3.0Creative Programming in ActionScript 3.0
Creative Programming in ActionScript 3.0Peter Elst
 
Actionscript 3 - Session 7 Other Note
Actionscript 3 - Session 7 Other NoteActionscript 3 - Session 7 Other Note
Actionscript 3 - Session 7 Other NoteOUM SAOKOSAL
 
How to create a simple image gallery in flash cs5
How to create a simple image gallery in flash cs5How to create a simple image gallery in flash cs5
How to create a simple image gallery in flash cs5Boy Jeorge
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 InheritanceOUM SAOKOSAL
 
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íTrung tâm Advance Cad
 
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 1Keziah Huong
 
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ảnTrung tâm Advance Cad
 
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 2Huytraining
 
Multimedia And Animation
Multimedia And AnimationMultimedia And Animation
Multimedia And AnimationRam Dutt Shukla
 

En vedette (19)

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
 
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
 
Chapter 9 Interface
Chapter 9 InterfaceChapter 9 Interface
Chapter 9 Interface
 
Action script for designers
Action script for designersAction script for designers
Action script for designers
 
Actionscript 3 - Session 2 Getting Started Flash IDE
Actionscript 3 - Session 2 Getting Started Flash IDEActionscript 3 - Session 2 Getting Started Flash IDE
Actionscript 3 - Session 2 Getting Started Flash IDE
 
Action Script
Action ScriptAction Script
Action Script
 
Creative Programming in ActionScript 3.0
Creative Programming in ActionScript 3.0Creative Programming in ActionScript 3.0
Creative Programming in ActionScript 3.0
 
Actionscript 3 - Session 7 Other Note
Actionscript 3 - Session 7 Other NoteActionscript 3 - Session 7 Other Note
Actionscript 3 - Session 7 Other Note
 
How to create a simple image gallery in flash cs5
How to create a simple image gallery in flash cs5How to create a simple image gallery in flash cs5
How to create a simple image gallery in flash cs5
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 Inheritance
 
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
 
Multimedia ppt
Multimedia pptMultimedia ppt
Multimedia ppt
 
Multimedia And Animation
Multimedia And AnimationMultimedia And Animation
Multimedia And Animation
 
Animation
AnimationAnimation
Animation
 

Similaire à ActionScript 3.0 Fundamentals Guide

Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad NicheTech Com. Solutions Pvt. Ltd.
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++Amresh Raj
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answersKrishnaov
 
Introduction to Core Java Programming
Introduction to Core Java ProgrammingIntroduction to Core Java Programming
Introduction to Core Java ProgrammingRaveendra R
 
iOS development introduction
iOS development introduction iOS development introduction
iOS development introduction paramisoft
 
Introduction to C++ Programming
Introduction to C++ ProgrammingIntroduction to C++ Programming
Introduction to C++ ProgrammingPreeti Kashyap
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...AnkurSingh340457
 
C# Summer course - Lecture 1
C# Summer course - Lecture 1C# Summer course - Lecture 1
C# Summer course - Lecture 1mohamedsamyali
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorialsakreyi
 
JavaScript OOPS Implimentation
JavaScript OOPS ImplimentationJavaScript OOPS Implimentation
JavaScript OOPS ImplimentationUsman Mehmood
 

Similaire à ActionScript 3.0 Fundamentals Guide (20)

C# concepts
C# conceptsC# concepts
C# concepts
 
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
iOS Application Development
iOS Application DevelopmentiOS Application Development
iOS Application Development
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
Interoduction to c++
Interoduction to c++Interoduction to c++
Interoduction to c++
 
Java notes
Java notesJava notes
Java notes
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
My c++
My c++My c++
My c++
 
Introduction to Core Java Programming
Introduction to Core Java ProgrammingIntroduction to Core Java Programming
Introduction to Core Java Programming
 
iOS development introduction
iOS development introduction iOS development introduction
iOS development introduction
 
Mca 504 dotnet_unit3
Mca 504 dotnet_unit3Mca 504 dotnet_unit3
Mca 504 dotnet_unit3
 
Introduction to C++ Programming
Introduction to C++ ProgrammingIntroduction to C++ Programming
Introduction to C++ Programming
 
Memory models in c#
Memory models in c#Memory models in c#
Memory models in c#
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
 
Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02Go f designpatterns 130116024923-phpapp02
Go f designpatterns 130116024923-phpapp02
 
C# Summer course - Lecture 1
C# Summer course - Lecture 1C# Summer course - Lecture 1
C# Summer course - Lecture 1
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
JavaScript OOPS Implimentation
JavaScript OOPS ImplimentationJavaScript OOPS Implimentation
JavaScript OOPS Implimentation
 

Dernier

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Dernier (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

ActionScript 3.0 Fundamentals Guide

  • 1. ActionScript 3.0 Fundamentals Saurabh Narula http://blog.saurabhnarula.com/
  • 2.
  • 3. ActionScript is the programming language for Adobe Flash Platform.
  • 4. Language specification is open source Open Source Compiler – as part of Flex SDK Open source Virtual Machine – Mozilla Tamarin
  • 5. Whats not open source .. Flash Player AIR
  • 6. Initially designed for controlling simple 2D vector animations, few interactivity features (may be that’s why its single threaded )
  • 7. ActionScript executes in ActionScript Virtual Machine (AVM) A new ActionScript Virtual Machine, called AVM2 – significant performance improvements over older AVM
  • 8. Before we get going on ActionScript fundamentals .. Lets have a brief look and understand what is a virtual machine ..
  • 9. Virtual Machine is essentially a virtual environment/OS running within a actual/host operating systems.
  • 10. In case of AVM , we talk about Process (Application) Virtual Machines and not System (Platform) Virtual Machines.
  • 11. Process VMs provide a platform-independent programming environment that abstracts details of the underlying hardware or OS. Allows program to execute the same way on all platforms.
  • 12. Process VM provide high level abstraction, for a high level programming language. This is done using an interpreter
  • 13. Programmer writes code in high level/human readable form which a machine can not understand .. so this source code has to be converted into machine code, this conversion is performed by Interpreter.
  • 14. Compiler makes the conversion once. Interpreter converts it every time a program is executed.
  • 15. Just in time Compilation (JIT) – offers improved runtime performance than interpreter.
  • 16. Interpreter interpret the byte code or sometimes interpret source code directly without having a byte code. These techniques offer lower performance.
  • 17. In case of JIT, a compiler can be used during execution – dynamic compilation . Remember – compilation from byte code to machine code is much faster than compiling from source.
  • 18. AVM2 takes ActionScript bytecode ABC file as an input.
  • 20. GC in flash player does not work constantly, only triggered by allocations.
  • 21. GC in flash player is iterative, doesn’t guarantee to find all collectible blocks in one pass.
  • 22. GC works by starting at the top of the object trees – Stage, ApplicationDomain/Class Definitions, Stack/Local Variables Mark the object and any objects they reference. Go through the heap and free anything that isn't marked.
  • 23. ActionScript is based on ECMAScript
  • 24. Event model based on the Document Object Model ( DOM ) Level 3 Events Specification
  • 25. DOM is a convention for representing and interacting with objects in HTML, XML type documents.
  • 26. Variables consists of 3 different parts – name, type of the data, actual value in computer’s memory
  • 27. Constant is same as variable but can be assigned only once.
  • 28. Using constants than a literal value makes code more readable. Change the value at one place than having it changed everywhere if using a hard-coded literal value. For example INTREST_RATE
  • 29. Data types Fundamental – single value like string, number, int, boolean etc .. Complex – set of values like Date.
  • 30. Creating objects is a way of organizing your code. In OOP related information and functionality is grouped together in form of objects.
  • 31. Class is a template or a blueprint of how object should look like, basis of the object creation.
  • 32. A Class can have Properties, Methods, Events.
  • 33. Property is data/information bundled within the object.
  • 34. To access a property you use “variable name-dot-property name” structure.
  • 35. A Method is an operation that object can perform, are not value placeholders.
  • 36. Event is essentially an event that happens which ActionScript is aware of and can respond to.
  • 37. Event Handling is an action that you perform in response to a particular event.
  • 38. Three important elements of Event handling – even source, event, response.
  • 39. function eventResponse(eventObject:EventType ):void { // Actions performed in response to the event go here. } eventSource .addEventListener( EventType.EVENT_NAME , eventResponse);
  • 40. Event handling - Compiler makes note of all the eventResponse() functions. Event source keeps a list of functions that are listening to each of its events. When the event happens, object is created for that event’s class and passes it on to eventResponse function.
  • 41. You directly instantiate a visual object by using it in MXML. For non visual objects you can instantiate them by using new operator or by assigning a literal value . Both approaches are same with a difference of calling base class constructor when using the new operator.
  • 42. You can build Flash applications using ActionScript 3.0 without using Flex SDK (create AS only project in Flash Builder), you can add AS code to frames in a timeline in Flash Professional.
  • 43. You can choose to Embed code in MXML files inside <fx:script> tag, alternatively you can import ActionScript code from an external file and specify the source attribute of the <fx:script> tag. You can also import the unstructured code using the include statement.
  • 44. Include an ActionScript Class using import statement.
  • 45. Flash Builder can be used to create apps using Flex SDK, and ActionScript only projects.
  • 46. You use Flash Professional when you want to create your visual assets (graphics, interactivities etc) and work with timeline/frames and write code in the same application.
  • 47. Other third party tools – FDT, TextMate (with AS, Flex bundles) etc.
  • 48. Class Design Considerations .. A class can be type value object, display object, supporting class.
  • 49. Class Design Considerations .. Your class can dispatch events if other parts of application need to know of some change.
  • 50. Class Design Considerations .. Consider creating a subclass if a class exists with a similar functionality.
  • 51. Lets take a detailed look at ActionScript 3.0 language and syntax.
  • 52. Objects and Classes .. All classes, built in or user defined derive from Object class.
  • 53. Objects and Classes .. var obj:*; //untyped object key differentiator – can hold undefined value, variable of type object cannot hold undefined.
  • 54. Packages and namespaces .. Related concepts but not same.
  • 55. Packages .. Implemented using namespaces (we will see later ..)
  • 56. Packages .. You can have variables, function, statements at the top level (and not just classes) but can only be public or internal.
  • 57. Packages .. Doesn’t support private classes
  • 58. Packages .. Main benefit – helps in avoiding name conflicts
  • 59. Packages .. Import statements should be as specific as possible. Import TestPackage.*; //avoid this – may lead to unexpected name conflicts. Import TestPackage.SomeClass;
  • 60. Packages .. Default access specifier for all members of package is internal.
  • 61. Packages .. Resolving name conflicts – import samples.SampleCode; import langref.samples.SampleCode; var mySample:SampleCode = new SampleCode(); // name conflict //use fully qualified names to resolve name conflicts var sample1:samples.SampleCode = new samples.SampleCode(); var sample2:langref.samples.SampleCode = new langref.samples.SampleCode();
  • 62. Namespaces .. Create your own namespace to define your own access control specifier.
  • 63. Namespaces .. You can attach a URI to the namespace definition, this makes sure that the definition is unique. If URI is not defined, compiler creates a unique identifier string in place of URI.
  • 64. Namespaces .. Cannot redefine a namespace in a same scope.
  • 65. Namespaces .. Can apply only one namespace to each declaration.
  • 66. Namespaces .. If you apply a namespace, you cannot also apply access control specifier.
  • 67. Packages are abstractions built on top of namespaces.
  • 69. Variable Scope .. There is no block level scope, interesting implication of this is that you can read or write variable before it is declared.
  • 70. Data Types .. Primitive type (boolean, int, number, string, uint) objects are stored as immutable objects, which means passing by reference is same as passing by value. Immutable objects - When you have a reference to an instance of object, the content of the instance can not be altered. Complex types/values are passed as reference.
  • 71. Type Checking .. Can occur at both compile and runtime.
  • 72. Type Checking .. You can set compiler to run in strict mode – type checking at both compile time and runtime or standard mode – only at runtime
  • 73. Type Checking .. Compile time checking is favored in case of large projects, catching type errors as early as possible is important.
  • 74. Type Checking .. when you use untyped object, you are not eliminating type checking but deferring it to the runtime.
  • 75. Type Checking .. Upcast – Use base class to declare the type of a class instance but use a subclass to instantiate it.
  • 76. is operator .. 1. Checks if the object is an instance of a particular class, 2. checks the inheritance hierarchy, 3. and if an object is an instance of a class that implements a particular interface.
  • 77. as operator .. Returns the value of the expression instead. Helps in ensuring that you are using a correct type.
  • 78. Dynamic classes .. Can attach properties and methods outside the class definition.
  • 79. Dynamic classes .. Type checking on dynamic properties is done at the runtime. Methods attached dynamically do not have access to private properties References to public properties or methods should be qualified with this or class name.
  • 80. Data Types .. Primitive – Boolean, int, Null, Number, String, Uint, void Complex – Object, Array, Date, Error, Function,
  • 81. Type Conversions .. Type conversions can be either implicit (coercion) or explicit (casting). Implicit conversions usually happen at the run time.
  • 82. Implicit Conversions .. Can happen at runtime – in assignment statements, when values passed as function arguments, when values are returned from functions, when using + operator
  • 83. Implicit Conversions .. For user-defined types , implicit conversions succeed when the value to be converted is an instance of the destination class or a class that derives from the destination class
  • 84. Implicit Conversions .. For primitive types , implicit conversion happens the same way as in case of explicit conversion.
  • 85. Explicit Conversions .. Good for type safety, will save you from any type conversion errors that might happen at the runtime.
  • 86. Casting to int, uint, Number .. Can cast any data type to one of these, if the conversion fails then default value 0 for int & uint is assigned and Nan for Number.
  • 87. Casting to Boolean .. Casting to Boolean from numeric types results in false if the numeric value is 0 and true otherwise.
  • 88. Casting to String .. From any numeric types .. Returns a string representation of number, in case of arrays ..a comma delimited string of all array elements would be returned.
  • 89. ActionScript syntax .. ActionScript is case sensitive.
  • 90. ActionScript syntax .. dot operator, literals, semicolons, parentheses, comments, keywords, reserve words, constants.
  • 91. Operators, Operator precedence and associatively ..
  • 92. Primary Operators .. Used for initializing array, object, group expression, calling a constructor etc. For eample [], {x:y}, (), new resp.
  • 93. Other Operators .. Postfix, Unary, multiplicative, additive, bitwise shift, relational, equality, bitwise logical, logical, conditional, assignment.
  • 94. Conditional Statements .. If, if .. else if, switch,
  • 95. Looping .. for, for .. In, for each .. In, while, do .. while
  • 96. Functions .. function statements vs. function expressions
  • 97. Function statements .. Less verbose, less confusing.
  • 98. Function Expressions .. Common use is that they are used only once and then discarded.
  • 99. Difference between function expression & function statement .. In case of dynamic classes/objects, delete has no effect on function statements
  • 100. Difference between function expression & function statement .. Can call function statement even before they are defined, not in case of fn expressions
  • 101. Functions .. return statement terminates the function, any statement after return is not executed.
  • 102. Nested functions .. Only available within its parent function unless a reference to the function is passed to outside code (function closures).
  • 103. Function parameters .. All arguments are passed by reference except primitive types.
  • 104. Functions parameters .. Number of arguments sent to a function can exceed the number of parameters defined for that function.
  • 105. Default parameters .. Is similar to making a parameter as optional, a parameter with no default value becomes a required parameter. All parameters with default values should ideally be placed in the end of parameter list in function signature.
  • 106. The arguments object .. Arguments is an array that includes all parameters passed to a function, argument.callee provides a reference to a function itself, which is useful for recursive calls (in function expressions).
  • 107. .. (rest) parameter specify array parameter that would allow you to accept any number of comma delimited parameters. Use of this makes arguments array unavailable.
  • 108. .. (rest) parameter can be used with other parameters, but should be the last parameter.
  • 109. Function as Objects .. Function passed as arguments to another function are passed as reference.
  • 110. Functions as objects .. Functions can have properties, methods like an object. It even has a read only property called length which stores the number of parameters defined for that function.
  • 111. Function scope .. Same scope rules that apply to variables, apply to functions.
  • 112. Scope Chain .. At the time of execution a activation object gets created that stores parameters and local variables, functions declared in the function body. We can not access activation object.
  • 113. Scope chain .. Scope chain is created that contains the ordered list of objects, against which the identifier declarations (variables) are checked.
  • 114. Scope chain .. Every function that executes has a scope chain, this is stored in an internal property. For example, for a nested function the scope chain starts with its own activation object, followed by its parent function’s activation object, until it reaches to global object. The global object is created when the ActionScript program begins, contains all global variables and functions.
  • 115. Function closures .. Object that contains a snapshot of a function and its lexical environment.
  • 116. Function closures .. Function closures retain the scope in which they were defined.
  • 117. Object Oriented Programming in ActionScript
  • 118. Classes abstract representation of object, usefulness of such an abstraction is apparent in big projects.
  • 119. Class attributes .. Dynamic – allow properties (classes and properties) to be added at runtime. Final – can not extend the class. Internal – visible only inside the current package. Public – visible everywhere
  • 120. Classes .. Can have a static property and instance property with the same name in the same class.
  • 121. Classes .. You can have statements in the class definition, which would execute only once.
  • 122. Class property attributes .. Internal, private, protected, public, static, User defined namespaces.
  • 123. Private variable .. In case of dynamic classes, accessing a private variable returns undefined instead of an error.
  • 124. Private variables .. Trying to access a private variable in strict mode using dot operator will generate a compile time error, and undefined in case of accessing using [] bracket . In standard mode, both cases will return undefined.
  • 125. Static .. Can be used with var, const, function. Attach property to class rather than to instance of the class.
  • 126. Static .. Static properties are part of a subclass’s scope chain, within a subclass a static variable or method can be used without referencing its class name.
  • 127. Variable .. Can be declared using var and const keyword.
  • 128. Variable .. variable declared as both const and static must be initialized at the same time as you declare it.
  • 129. Instance variables .. Cannot override var/const directly, can override setters/getters though.
  • 130. Constructor methods .. Can only be public, doesn’t return any value.
  • 131. Constructor methods .. Can explicitly call the super class constructor by using super(), compiler calls it if not explicitly called.
  • 132. Constructor methods .. When using super statement with super(), always call super() first.
  • 133. Static methods .. Does not affect a specific instance of a class, you can use this or super within the body of the static method. Not inherited but are in scope.
  • 134. Instance methods .. Redefine an inherited method, final attribute is used to prevent subclasses from overriding a method.
  • 135. Getters and setters .. Access class properties which are private as if you are accessing directly instead of calling a method. Avoids using names like getPropertyName(), setPropertyName()
  • 136. Getters and setters .. Can use override attribute on getter and setter functions.
  • 137. Bound methods .. Similar to function closure, this reference in a bound method remains bound to the instance that implements the method, whereas this reference is generic in case of function closure.
  • 138. Enumerations .. Custom data types that you create to encapsulate small set of values.
  • 139. Embedded asset classes .. [Embed] metadata tag, @Embed in MXML.
  • 140. Interfaces .. Method declarations that allow unrelated objects to communicate with each other, i.e serves as a protocol.
  • 141. Interfaces .. Any class that implements interface is responsible for defining the method implementations.
  • 142. Interfaces .. Can not include variables or constants but can include getters and setters.
  • 143. Interfaces .. Can be public or internal. Method definitions inside an interface can not have access specifiers. Interfaces can extend another interface.
  • 144. Interfaces .. While implementing an interface, make sure number of parameters and the data type of each parameter is same, in case of default parameter not necessary to specify the same default values.
  • 145. Inheritance .. Code reuse. Subclass is guaranteed to possess all the properties of its base class.
  • 146. Inheritance .. Can take advantage of polymorphism by inheriting and overriding methods.
  • 147. Inheritance .. Instance of a subclass can always be substituted for an instance of the base class.
  • 148. Inheritance - Overriding methods Names of the parameters in the override method do not have to match the names of the parameters in the base class, as long as the number of parameters and the data type of each parameter matches.
  • 149. Inheritance - Static Properties If an instance property is defined that uses the same name as a static property in the same class or a superclass, the instance property has higher precedence in the scope chain.

Notes de l'éditeur

  1. Some operators are overloaded, for example +, - operator is both unary and binary operator.
  2. Postfix operator has higher precedence,
  3. Function expressions is more verbose, used in earlier versions of actionscript. Function expressions can be used as part of a statement.
  4. Cant use other access specifiers including namespaces.