Top Banner
25

Introduction to Actionscript3

Nov 19, 2014

Download

Technology

Yossi Cohen

Introduction to ActionScript3, differences from ActionScript2, פלאש
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to Actionscript3
Page 2: Introduction to Actionscript3

Adobe Platform Mastering

•Technology overview•AVM1 and AVM2•AS3 new features•AS2 migration to AS3•Coding samples•Performance tips•The future•Questions

Page 3: Introduction to Actionscript3

Adobe Platform Mastering

•Flash Player 2 – timeline control commands•Flash Player 3 – load movie•Flash Player 4 – Full scripting implementation

(Actions, loops, variables, conditions)•Flash Player 5- AS1 (prototyped based on

ECMA, procedural and OOP)•Flash Player 6 – AS1 + Events model, RTMP

support, minor language improvements

Page 4: Introduction to Actionscript3

Adobe Platform Mastering

•Flash Player 7 – AS2 introduction (ECMA4), inheritance, CSS support , FP6 support

•Flash Player 8 – AS1/AS2 improvements, mostly graphical, File uploads

•Flash Player 9(8.5) – AS3 introduction, AVM2, JIT compilation, Binary sockets, E4X, RegEx

•Flash Player 10, AIR – the future

Page 5: Introduction to Actionscript3

Adobe Platform Mastering

•Introduced September 2003 – Flash MX 2004

•Features▫Compile time type checking▫Class based syntax▫Strict typing▫Inheritance▫ECMA 4 partially

Page 6: Introduction to Actionscript3

Adobe Platform Mastering

•Introduced June 2006 – Adobe Flex 2•Features

▫New AVM2▫2 AVMs in FP9 player▫Performance improvement▫New bytecode compilation▫Packages support▫ECMA4 completely

Page 7: Introduction to Actionscript3

Adobe Platform Mastering

Page 8: Introduction to Actionscript3

Adobe Platform Mastering

•Performance▫Using strict typing▫Complete rewritten AVM▫Comparison example

•Sophistication▫Complete class support

•No hacks needed

Page 9: Introduction to Actionscript3

Adobe Platform Mastering

•Evolution of Actionscript 2.0•Full re-engineered for performance•Final and Dynamic classes•Runtime exception•E4X•RegEx

Page 10: Introduction to Actionscript3

Adobe Platform Mastering

•Type declaration required (warning)•Public, internal, protected, private, final•Packages •Constants•Int, Uint•* vs. Object•… parameter•More runtime and compile time errors•For each in (E4X)

Page 11: Introduction to Actionscript3

Adobe Platform Mastering

•Completely re-write and organize•More object oriented•Event Model•Display tree exposed•Binary Socket•Binary Data – Bytes Array

•More: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/migration.html

Page 12: Introduction to Actionscript3

Adobe Platform Mastering

•Display objects treated as objects▫Reparenting▫Handling without display▫Resource management…

•Dynamic content, removing idle actions•Loaded content (untrusted content)•System.totalmemory (process memory info)•Weak reference – listeners, Dictionary•Garbage collection reference:

http://www.adobe.com/devnet/flashplayer/articles/garbage_collection.html

Page 13: Introduction to Actionscript3

Adobe Platform Mastering

•Flash CS3 •Flex 3

▫Actionscript project▫Flex project

•Flex SDK – open source•Flex SDK for player 10 beta

Page 14: Introduction to Actionscript3

Adobe Platform Mastering

•FP9 SWF•FP10 SWF•Air application•Projector application

Page 15: Introduction to Actionscript3

Adobe Platform Mastering

•Http▫Server side scripts (ASP, PHP), SOAP, REST▫Images, Progressive download▫File reference

•RTMP▫FMS, Red5 – streaming ▫Flash remoting

Page 16: Introduction to Actionscript3

Adobe Platform Mastering

•Binary Sockets + binary data▫TCP, FTP, SMTP etc…

•External Interface▫Desktop application wrapper, Javascript

•Local Connection▫Communication between movies▫AVM1 – AVM2

•AIR

Page 17: Introduction to Actionscript3

Adobe Platform Mastering

•Say goodbye to: attachAudio, attachBitmap, attachMovie, createEmptyMovieClip, createTextField, duplicateMovieClip, swapDepths, removeMovieClip

•Say hello to: DisplayObjectContainer, addChild, removeChild

Page 18: Introduction to Actionscript3

Adobe Platform Mastering

Page 19: Introduction to Actionscript3

Adobe Platform Mastering

•DisplayObject – base class, cannot contain additional DisplayObject

•InteractiveObject – supporting user interaction, such as buttons and text fields

•DisplayObjectContainer – can contain additional DisplayObject

•MovieClip – sprite with timeline•root => stage•Examples…

Page 20: Introduction to Actionscript3

Adobe Platform Mastering

•AS2▫Callback : onLoad, onData, onPress▫Events: addListener

•AS3 ▫Events Model

Decoupling Asynchronic execution

▫No more Delegation

Page 21: Introduction to Actionscript3

Adobe Platform Mastering

•Event System▫Event dispatcher▫Event listener▫Event object

•EventDispatcher class addEventListener dispatchEvent removeEventListener …

•Example…

Page 22: Introduction to Actionscript3

Adobe Platform Mastering

•Event Propagation▫Capture▫At target ▫Bubbling▫Example…

•Event Object▫Creating custom events ▫Example…

Page 23: Introduction to Actionscript3

Adobe Platform Mastering

•XML Structure▫Tree structure of data, built by nodes, properties and

values

•XML Loading▫URLLoader, URLRequest ▫XML

•Example…•XML Reading•XML Filtering

Page 24: Introduction to Actionscript3

Adobe Platform Mastering

•XML Reading▫XML – direct data access▫XMLList – indirect data access (for each in, for)

Children() Attributes() Attribute(attName:String)

•XML Filtering▫Node values (name == value)▫Attributes (@attName == value)

•Examples…..

Page 25: Introduction to Actionscript3

Adobe Platform Mastering

•Flash Player 10▫Communication▫File system access ▫Etc.

•Actionscript 4.0▫Array typing▫Union typing▫More primitives▫ECMA 4 compatible (December 2008 spec

release)▫And many more…..