SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Flash and the DOM
        Why you still need to know JavaScript


            *not* AIR and AJAX !

by Mike Wilcox
mwilcox@sitepen.com
Twitter: #clubajax
http://clubajax.org
Mike




© SitePen, Inc. 2009. All Rights Reserved
© SitePen, Inc. 2009. All Rights Reserved
My Flash and JavaScript
                                 background



© SitePen, Inc. 2009. All Rights Reserved
What we will discuss
                    ActionScript & JavaScript similarities and differences
                    The embed & object code
                    ActionScript JavaScript Communication
                    Flash DOM gotchas
                    Future of Flash




© SitePen, Inc. 2009. All Rights Reserved
I don't need to know about browser issues -
        because I code in ActionScript!
                                            - Mike circa 2002




© SitePen, Inc. 2009. All Rights Reserved
Flash in the browser
                    You're still at the mercy of the container (the browser)
                    IE, Firefox, Safari (WebKit) all have different problems
                    implementing the Flash plugin
                    There may come a time when the customer wants that
                    full-page Flex app to interact with their existing HTML
                    code




© SitePen, Inc. 2009. All Rights Reserved
ActionScript & JavaScript
                                            Similarities and Differences




© SitePen, Inc. 2009. All Rights Reserved
Language Similarities
                    Both based on the ECMAScript standard
                    AS1 and JavaScript very similar
                    AS2 still similar but with classes and packages
                    AS3 actually more like Java with closures
                          AS3 based on early ECMAScript 2 which has since
                          changed

                    Key difference is Document and Stage, MovieClips and
                    DOM Nodes



© SitePen, Inc. 2009. All Rights Reserved
ActionScript & JavaScript
                    Both scripting languages
                          SWF compiler combines scripts, removes whitespace and
                          comments, mini es variables, turns it into bytecode, and
                          compresses.
                          AJAX build tools combine scripts, remove whitespace and
                          comments, minify the variables. The end result is then
                          compressed using GZIP on the server.

                    Key difference is the SWF wrapper holds all media
                    (images, sounds, etc.)



© SitePen, Inc. 2009. All Rights Reserved
SWF and HTML both stream
                    Actually both are progressive download
                    SWF compilers assemble the pieces so that elements can
                    display and run when enough data has downloaded
                    HTML page streams line by line and executes or displays




© SitePen, Inc. 2009. All Rights Reserved
Web APIs / Web Services
                    JavaScript: XHR and JSONP
                          XHR (XmlHttpRequest) has cross domain issues
                          eval sends a string to the JavaScript engine to be
                          interpreted
                                 eval(“alert(1 + 2);”); // alerts 3

                    Flash: XML & Remoting
                          XML is heavy on the wire
                          Remoting needs a server that handles it

                    crossdomain.xml - newer browsers are supporting this
© SitePen, Inc. 2009. All Rights Reserved
Embedding the SWF
                In the meantime, Eolas might sue every last,
                        lousy company in creation




© SitePen, Inc. 2009. All Rights Reserved
The bare bones embed object

         <object>
            <param name=movie value="myMovie.swf">
            <embed src="myMovie.swf" />
         </object>




© SitePen, Inc. 2009. All Rights Reserved
object vs. embed
                    object for IE
                          object node has attributes
                          object has child nodes with more attributes
                    embed for everyone else
                          No child attributes
                          Can be a child of the object node




© SitePen, Inc. 2009. All Rights Reserved
A more typical embed object
         <object width="480" height="270" align="middle"
         codebase="http://download.macromedia.com/pub/shockwave/cabs/
         flash/swflash.cab#version=9,0,0,0" classid="clsid:d27cdb6e-
         ae6d-11cf-96b8-444553540000" name="my__player" id="my__player">
         
 <param value="always" name="allowScriptAccess"/>
         
 <param value="true" name="allowFullScreen"/>
         
 <param value="http://flash.local/my__player.swf?
         prefsfile=http://flash.local/xml/prefs_skunk.xml" name="movie"/>
         
 <param value="my_movie" name="name"/>
         
 <param value="my_movie" name="id"/>
         
 <param value="high" name="quality"/>
         
 <param value="#ffffff" name="bgcolor"/>
         
 <embed width="480" height="270" align="middle"
         pluginspage="http://www.macromedia.com/go/getflashplayer"
         type="application/x-shockwave-flash" allowfullscreen="true"
         allowscriptaccess="always" name="my__player" bgcolor="#ffffff"
         quality="high" src="http://flash.local/my__player.swf?
         prefsfile=http://flash.local/xml/prefs_skunk.xml"/>
         </object>


© SitePen, Inc. 2009. All Rights Reserved
Attributing Attributes - object
                    Root attributes
                          width, height, align, codebase, classid, name, id

                    Child attributes - passed to the player once it is started.
                          allowScriptAccess, allowFullScreen, movie (src), wmode,
                          swLiveConnect




© SitePen, Inc. 2009. All Rights Reserved
Attributing Attributes - embed
                    Can be a root node or child of object node
                          As a child, browser determine whther to ignore the
                          embed tags or the object tags

                    No embed child nodes
                    Root attributes
                          width, height, align, name, id, allowScriptAccess,
                          allowFullScreen, src, wmode, pluginspage, type,
                          swLiveConnect




© SitePen, Inc. 2009. All Rights Reserved
Solution: Dynamic embedding
                    With thanks to that damn Eolas
                    More control over the myriad attributes
                    Better reusability
                    Most attributes can be preset
                    Sets up ExternalInterface for you
                    Fires events for SWF readiness
                    Bonus: SEO!



© SitePen, Inc. 2009. All Rights Reserved
Dynamic embedding libraries
                    SWFObject
                    dojox.embed.Flash
                    AC_RunActiveContent.js
                    Mike’s custom code




© SitePen, Inc. 2009. All Rights Reserved
Mike’s custom code example
         <body>
         
 <div align=center>
         
 
 <script src="mike.js" id="MIKE"
         
 
 
 config="swf=my_player,width=480,height=270" >
         
 
 </script>
         
 </div>
         </body>




© SitePen, Inc. 2009. All Rights Reserved
Mike’s custom code highlights
         // find where this script is attached in the dom
         var snode;
         var scripts = document.getElementsByTagName("script");
         for (var i = 0; i < scripts.length; i++) {
         
 if (scripts[i].id && scripts[i].id == "MIKE") {
         
 
 snode = scripts[i];
         
 
 break;
         
 }
         }

         // Get the variables from the config attribute in the script
         var configStr = snode.getAttribute("config");
         var attrs = convertToAttributes(configStr);

         // The parent node of the script is where we insert the SWF
         playerdiv = snode.parentNode;
         playerdiv.style.width = flashArgs.width;
         playerdiv.style.height = flashArgs.height;



© SitePen, Inc. 2009. All Rights Reserved
Mike’s custom code the embed object
         var str = '<object id="'+args.id+'" name="'+args.id+'" '
         
 + 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
         
 + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/
         flash/swflash.cab#version=9,0,0,0" '
         
 + 'width="'+args.width+'" height="'+args.height+'">'
         
 
 + '<param name="allowScriptAccess" value="'+args.asa+'" />'
         
 
 + '<param name="allowFullScreen" value="'+args.fs+'" />'
         
 
 + '<param name="movie" value="'+args.id+'" />'
         
 
 + '<param name="name" value="'+args.src+'" />'
         
 
 + '<param name="id" value="'+args.id+'" />'
         
 
 + '<param name="wmode" value="'+args.wmode+'" />'
         
 + '<embed src="'+args.src+'" '
         
 
 + 'width="'+args.width+'" height="'+args.height+'" '
         
 
 + 'name="'+args.id+'" '
         
 
 + 'allowScriptAccess="'+args.asa+'" '
         
 
 + 'allowFullScreen="'+args.fs+'" '
         
 
 + 'wmode="'+args.wmode+'" '
         
 
 + 'type="application/x-shockwave-flash" '
         
 
 + 'pluginspage="http://www.macromedia.com/go/
         getflashplayer" />'
         + '</object>';

© SitePen, Inc. 2009. All Rights Reserved
embed and object in the same doc?
                    Most libraries do a browser sniff and only use one or the
                    other
                    In my opinion this is unnecessary because:
                          Modern browsers elegantly ignore the other tag
                          No bytes on the wire saved
                          The dynamic code base is more complex
                          The browser sniffing is what adds bytes on the wire and
                          execution time to for parsing

                          You lose the ability for the YouTube embed

© SitePen, Inc. 2009. All Rights Reserved
Getting that movie
         var swfById = function (movieName){
         
 if(document.embeds[movieName]){
         
 
 return document.embeds[movieName];
         
 }
         
 if(document[movieName]){
         
 
 return doc[movieName];
         
 }
         
 if(window[movieName]){
         
 
 return window[movieName];
         
 }
         
 if(document[movieName]){
         
 
 return document[movieName];
         
 }
         
 return null;
         }




© SitePen, Inc. 2009. All Rights Reserved
Getting ActionScript and
                            JavaScript to Talk
                                        Mommy! Daddy! Stop ghting!




© SitePen, Inc. 2009. All Rights Reserved
AS / JS Communication
                    ExternalInterface
                    FlashVars
                    GetVariable/SetVariable
                          Largely deprecated for AS3

                    Movie properties
                          Primarily PercentLoaded

                    fscommand
                          Complete with VB Script! Which thankfully died a bloody
                          death
© SitePen, Inc. 2009. All Rights Reserved
ExternalInterface
                    Introduced in Flash 8 after years of abusive punishment
                    to devs, forcing them to use the fscommand
                    And then the Flash 8 EI was coded by drunken sailors
                    Flash 9 EI much better
                    But you still have craziness like this patch:

         window.attachEvent('onunload', function() {
         
 window.__flash__removeCallback = function (instance, name) {
         
 
 try {
         
 
 
 if (instance) instance[name] = null;
         
 
 } catch ( err ) { }
         
 };
         });


© SitePen, Inc. 2009. All Rights Reserved
ExternalInterface Examples




© SitePen, Inc. 2009. All Rights Reserved
FlashVars
                    FlashVars attribute introduced in Flash 6 although the
                    query string was used before that and there’s little
                    difference
                    No complex objects without serialization - similar to
                    sephiroth library
                    Examples of the need for FlashVars:
                          Dynamic creation, as in the Dojo FileUploader
                          URLs to connect to




© SitePen, Inc. 2009. All Rights Reserved
FlashVars
         <object>
         
 <param name=movie value="myMovie.swf">
         
 <param name=FlashVars value="user=Mike&score=1000">
         
 <embed src="myMovie.swf" FlashVars="user=Mike&score=1000" />
         </object>

         or

         <object>
         
 <param name=movie value="myMovie.swf?user=Mike&score=1000">
         
 <embed src="myMovie.swf?user=Mike&score=1000" />
         </object>

         // accessed in AS2 in _root:
         _root.user

         // accessed in AS3:
         var params = LoaderInfo(this.root.loaderInfo).parameters;
         params.user;


© SitePen, Inc. 2009. All Rights Reserved
FlashVars Examples




© SitePen, Inc. 2009. All Rights Reserved
Flash/Browser Gotchas



© SitePen, Inc. 2009. All Rights Reserved
Flash/Browser Gotchas
                          Flash will not initialize in a node with display=”none”
                          DOM must be "ready" before the SWF can be inserted in
                          node - using window.onload (or something better)
                          Watch IE6 & IE7 Memory leaks - especially when using the
                          ExternalInterface
                          Detecting Mouse Events outside of SWF
                          TabIndex between a SWF and HTML is non-existent
                          You've heard those stories of bad Java applet
                          implementations? Flash isn't a whole lot better.


© SitePen, Inc. 2009. All Rights Reserved
Future of Flash
                                               FutureSplash
                                             ShockWaveFlash
                                             Macromedia Flash
                                               Adobe Flash
                                              Microsoft Flash



© SitePen, Inc. 2009. All Rights Reserved
Is Flash Dead?
        Rumors of my death have been greatly
        exaggerated.
                                    - Paul McCartney




© SitePen, Inc. 2009. All Rights Reserved
Open Source
        But then everyone will see my code and steal all
        of my fantastically incredible ideas!
                                         - Mike circa 2002




© SitePen, Inc. 2009. All Rights Reserved
HSO: AS3 was a mistake
                                            - Mike circa today




© SitePen, Inc. 2009. All Rights Reserved
Q&A




© SitePen, Inc. 2009. All Rights Reserved
Thank you!



© SitePen, Inc. 2009. All Rights Reserved

Weitere ähnliche Inhalte

Was ist angesagt?

Adobe AEM CQ5 - Developer Introduction
Adobe AEM CQ5 - Developer IntroductionAdobe AEM CQ5 - Developer Introduction
Adobe AEM CQ5 - Developer IntroductionYash Mody
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Webphilogb
 
Adobe CQ5 for Developers - Introduction
Adobe CQ5 for Developers - IntroductionAdobe CQ5 for Developers - Introduction
Adobe CQ5 for Developers - IntroductionTekno Point
 
Catch 22: FLex APps
Catch 22: FLex APpsCatch 22: FLex APps
Catch 22: FLex APpsYash Mody
 
Develop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will loveDevelop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will loveChris Love
 
A 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersA 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersMark Leusink
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPressTaylor Lovett
 
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignalBuilding modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignalAlessandro Pilotti
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizationsChris Love
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseTaylor Lovett
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentIrfan Maulana
 
Isomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPIsomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPTaylor Lovett
 
HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1James Pearce
 
Best Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress MultisiteBest Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress MultisiteTaylor McCaslin
 
Advanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms toolsAdvanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms toolsChris Love
 
BP101: A Modernized Workflow w/ Domino/XPages
BP101: A Modernized Workflow w/ Domino/XPagesBP101: A Modernized Workflow w/ Domino/XPages
BP101: A Modernized Workflow w/ Domino/XPagesedm00se
 
Extreme Web Performance for Mobile Devices - Velocity NY
Extreme Web Performance for Mobile Devices - Velocity NYExtreme Web Performance for Mobile Devices - Velocity NY
Extreme Web Performance for Mobile Devices - Velocity NYMaximiliano Firtman
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN StackRob Davarnia
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesMark Roden
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Timothy Fisher
 

Was ist angesagt? (20)

Adobe AEM CQ5 - Developer Introduction
Adobe AEM CQ5 - Developer IntroductionAdobe AEM CQ5 - Developer Introduction
Adobe AEM CQ5 - Developer Introduction
 
Using Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the WebUsing Web Standards to create Interactive Data Visualizations for the Web
Using Web Standards to create Interactive Data Visualizations for the Web
 
Adobe CQ5 for Developers - Introduction
Adobe CQ5 for Developers - IntroductionAdobe CQ5 for Developers - Introduction
Adobe CQ5 for Developers - Introduction
 
Catch 22: FLex APps
Catch 22: FLex APpsCatch 22: FLex APps
Catch 22: FLex APps
 
Develop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will loveDevelop a vanilla.js spa you and your customers will love
Develop a vanilla.js spa you and your customers will love
 
A 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersA 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developers
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignalBuilding modern web sites with ASP .Net Web API, WebSockets and RSignal
Building modern web sites with ASP .Net Web API, WebSockets and RSignal
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
PHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
 
Isomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPIsomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWP
 
HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1HTML5 and the dawn of rich mobile web applications pt 1
HTML5 and the dawn of rich mobile web applications pt 1
 
Best Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress MultisiteBest Friend || Worst Enemy: WordPress Multisite
Best Friend || Worst Enemy: WordPress Multisite
 
Advanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms toolsAdvanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms tools
 
BP101: A Modernized Workflow w/ Domino/XPages
BP101: A Modernized Workflow w/ Domino/XPagesBP101: A Modernized Workflow w/ Domino/XPages
BP101: A Modernized Workflow w/ Domino/XPages
 
Extreme Web Performance for Mobile Devices - Velocity NY
Extreme Web Performance for Mobile Devices - Velocity NYExtreme Web Performance for Mobile Devices - Velocity NY
Extreme Web Performance for Mobile Devices - Velocity NY
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
 

Andere mochten auch

나는 PM이다! 30회 진혜경 발표자료
나는 PM이다! 30회 진혜경 발표자료나는 PM이다! 30회 진혜경 발표자료
나는 PM이다! 30회 진혜경 발표자료Dong-Hwan Han, Ph.D.
 
Restaurant Roll-up Transaction
Restaurant Roll-up TransactionRestaurant Roll-up Transaction
Restaurant Roll-up TransactionAlex W. Howard
 
知慧의 장 정보지_10월호
知慧의 장 정보지_10월호知慧의 장 정보지_10월호
知慧의 장 정보지_10월호Seon Hong Kim
 
ICANN 51 로스앤젤레스 비즈니스 다이제스트
 ICANN 51 로스앤젤레스 비즈니스 다이제스트  ICANN 51 로스앤젤레스 비즈니스 다이제스트
ICANN 51 로스앤젤레스 비즈니스 다이제스트 ICANN
 
천연미장 기법 강의20150503
천연미장 기법 강의20150503천연미장 기법 강의20150503
천연미장 기법 강의20150503Seongwon Kim
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?Maciej Lasyk
 

Andere mochten auch (6)

나는 PM이다! 30회 진혜경 발표자료
나는 PM이다! 30회 진혜경 발표자료나는 PM이다! 30회 진혜경 발표자료
나는 PM이다! 30회 진혜경 발표자료
 
Restaurant Roll-up Transaction
Restaurant Roll-up TransactionRestaurant Roll-up Transaction
Restaurant Roll-up Transaction
 
知慧의 장 정보지_10월호
知慧의 장 정보지_10월호知慧의 장 정보지_10월호
知慧의 장 정보지_10월호
 
ICANN 51 로스앤젤레스 비즈니스 다이제스트
 ICANN 51 로스앤젤레스 비즈니스 다이제스트  ICANN 51 로스앤젤레스 비즈니스 다이제스트
ICANN 51 로스앤젤레스 비즈니스 다이제스트
 
천연미장 기법 강의20150503
천연미장 기법 강의20150503천연미장 기법 강의20150503
천연미장 기법 강의20150503
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 

Ähnlich wie Flash And Dom

Flash Security, OWASP Chennai
Flash Security, OWASP ChennaiFlash Security, OWASP Chennai
Flash Security, OWASP Chennailavakumark
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs SilverlightMatt Casto
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and moreYan Shi
 
Web app and more
Web app and moreWeb app and more
Web app and morefaming su
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Sadaaki HIRAI
 
Leveraging BlazeDS, Java, and Flex: Dynamic Data Transfer
Leveraging BlazeDS, Java, and Flex: Dynamic Data TransferLeveraging BlazeDS, Java, and Flex: Dynamic Data Transfer
Leveraging BlazeDS, Java, and Flex: Dynamic Data TransferJoseph Labrecque
 
WordCamp Thessaloniki2011 The NextWeb
WordCamp Thessaloniki2011 The NextWebWordCamp Thessaloniki2011 The NextWeb
WordCamp Thessaloniki2011 The NextWebGeorge Kanellopoulos
 
Content-Security-Policy 2018.0
Content-Security-Policy 2018.0Content-Security-Policy 2018.0
Content-Security-Policy 2018.0Philippe Gamache
 
Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008Jeremiah Grossman
 
HTML5 Intoduction for Web Developers
HTML5 Intoduction for Web DevelopersHTML5 Intoduction for Web Developers
HTML5 Intoduction for Web DevelopersSascha Corti
 
Firefox OS in Japan
Firefox OS in JapanFirefox OS in Japan
Firefox OS in Japandynamis
 
The Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devicesThe Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devicesWesley Hales
 

Ähnlich wie Flash And Dom (20)

HTML5와 모바일
HTML5와 모바일HTML5와 모바일
HTML5와 모바일
 
Flash Security, OWASP Chennai
Flash Security, OWASP ChennaiFlash Security, OWASP Chennai
Flash Security, OWASP Chennai
 
Attacking HTML5
Attacking HTML5Attacking HTML5
Attacking HTML5
 
HTML5 vs Silverlight
HTML5 vs SilverlightHTML5 vs Silverlight
HTML5 vs Silverlight
 
Echo HTML5
Echo HTML5Echo HTML5
Echo HTML5
 
Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
A look into A-Frame
A look into A-FrameA look into A-Frame
A look into A-Frame
 
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
Familiar HTML5 - 事例とサンプルコードから学ぶ 身近で普通に使わているHTML5
 
Word camp nextweb
Word camp nextwebWord camp nextweb
Word camp nextweb
 
Word camp nextweb
Word camp nextwebWord camp nextweb
Word camp nextweb
 
Sanjeev ghai 12
Sanjeev ghai 12Sanjeev ghai 12
Sanjeev ghai 12
 
Leveraging BlazeDS, Java, and Flex: Dynamic Data Transfer
Leveraging BlazeDS, Java, and Flex: Dynamic Data TransferLeveraging BlazeDS, Java, and Flex: Dynamic Data Transfer
Leveraging BlazeDS, Java, and Flex: Dynamic Data Transfer
 
WordCamp Thessaloniki2011 The NextWeb
WordCamp Thessaloniki2011 The NextWebWordCamp Thessaloniki2011 The NextWeb
WordCamp Thessaloniki2011 The NextWeb
 
Content-Security-Policy 2018.0
Content-Security-Policy 2018.0Content-Security-Policy 2018.0
Content-Security-Policy 2018.0
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008Top Ten Web Hacking Techniques – 2008
Top Ten Web Hacking Techniques – 2008
 
HTML5 Intoduction for Web Developers
HTML5 Intoduction for Web DevelopersHTML5 Intoduction for Web Developers
HTML5 Intoduction for Web Developers
 
Firefox OS in Japan
Firefox OS in JapanFirefox OS in Japan
Firefox OS in Japan
 
The Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devicesThe Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devices
 

Mehr von Mike Wilcox

Accessibility for Fun and Profit
Accessibility for Fun and ProfitAccessibility for Fun and Profit
Accessibility for Fun and ProfitMike Wilcox
 
Webpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need itWebpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need itMike Wilcox
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 
Great Responsive-ability Web Design
Great Responsive-ability Web DesignGreat Responsive-ability Web Design
Great Responsive-ability Web DesignMike Wilcox
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsMike Wilcox
 
Model View Madness
Model View MadnessModel View Madness
Model View MadnessMike Wilcox
 
Hardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightHardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightMike Wilcox
 
The Great Semicolon Debate
The Great Semicolon DebateThe Great Semicolon Debate
The Great Semicolon DebateMike Wilcox
 
AMD - Why, What and How
AMD - Why, What and HowAMD - Why, What and How
AMD - Why, What and HowMike Wilcox
 
Webpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersWebpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersMike Wilcox
 
Why You Need a Front End Developer
Why You Need a Front End DeveloperWhy You Need a Front End Developer
Why You Need a Front End DeveloperMike Wilcox
 
A Conversation About REST
A Conversation About RESTA Conversation About REST
A Conversation About RESTMike Wilcox
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5Mike Wilcox
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5Mike Wilcox
 
How to get a Job as a Front End Developer
How to get a Job as a Front End DeveloperHow to get a Job as a Front End Developer
How to get a Job as a Front End DeveloperMike Wilcox
 
The History of HTML5
The History of HTML5The History of HTML5
The History of HTML5Mike Wilcox
 

Mehr von Mike Wilcox (20)

Accessibility for Fun and Profit
Accessibility for Fun and ProfitAccessibility for Fun and Profit
Accessibility for Fun and Profit
 
WTF R PWAs?
WTF R PWAs?WTF R PWAs?
WTF R PWAs?
 
Advanced React
Advanced ReactAdvanced React
Advanced React
 
Webpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need itWebpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need it
 
Dangerous CSS
Dangerous CSSDangerous CSS
Dangerous CSS
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
Great Responsive-ability Web Design
Great Responsive-ability Web DesignGreat Responsive-ability Web Design
Great Responsive-ability Web Design
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
 
Model View Madness
Model View MadnessModel View Madness
Model View Madness
 
Hardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightHardcore JavaScript – Write it Right
Hardcore JavaScript – Write it Right
 
The Great Semicolon Debate
The Great Semicolon DebateThe Great Semicolon Debate
The Great Semicolon Debate
 
AMD - Why, What and How
AMD - Why, What and HowAMD - Why, What and How
AMD - Why, What and How
 
Dojo & HTML5
Dojo & HTML5Dojo & HTML5
Dojo & HTML5
 
Webpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersWebpage Design Basics for Non-Designers
Webpage Design Basics for Non-Designers
 
Why You Need a Front End Developer
Why You Need a Front End DeveloperWhy You Need a Front End Developer
Why You Need a Front End Developer
 
A Conversation About REST
A Conversation About RESTA Conversation About REST
A Conversation About REST
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
 
How to get a Job as a Front End Developer
How to get a Job as a Front End DeveloperHow to get a Job as a Front End Developer
How to get a Job as a Front End Developer
 
The History of HTML5
The History of HTML5The History of HTML5
The History of HTML5
 

Kürzlich hochgeladen

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Kürzlich hochgeladen (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Flash And Dom

  • 1. Flash and the DOM Why you still need to know JavaScript *not* AIR and AJAX ! by Mike Wilcox mwilcox@sitepen.com Twitter: #clubajax http://clubajax.org
  • 2. Mike © SitePen, Inc. 2009. All Rights Reserved
  • 3. © SitePen, Inc. 2009. All Rights Reserved
  • 4. My Flash and JavaScript background © SitePen, Inc. 2009. All Rights Reserved
  • 5. What we will discuss ActionScript & JavaScript similarities and differences The embed & object code ActionScript JavaScript Communication Flash DOM gotchas Future of Flash © SitePen, Inc. 2009. All Rights Reserved
  • 6. I don't need to know about browser issues - because I code in ActionScript! - Mike circa 2002 © SitePen, Inc. 2009. All Rights Reserved
  • 7. Flash in the browser You're still at the mercy of the container (the browser) IE, Firefox, Safari (WebKit) all have different problems implementing the Flash plugin There may come a time when the customer wants that full-page Flex app to interact with their existing HTML code © SitePen, Inc. 2009. All Rights Reserved
  • 8. ActionScript & JavaScript Similarities and Differences © SitePen, Inc. 2009. All Rights Reserved
  • 9. Language Similarities Both based on the ECMAScript standard AS1 and JavaScript very similar AS2 still similar but with classes and packages AS3 actually more like Java with closures AS3 based on early ECMAScript 2 which has since changed Key difference is Document and Stage, MovieClips and DOM Nodes © SitePen, Inc. 2009. All Rights Reserved
  • 10. ActionScript & JavaScript Both scripting languages SWF compiler combines scripts, removes whitespace and comments, mini es variables, turns it into bytecode, and compresses. AJAX build tools combine scripts, remove whitespace and comments, minify the variables. The end result is then compressed using GZIP on the server. Key difference is the SWF wrapper holds all media (images, sounds, etc.) © SitePen, Inc. 2009. All Rights Reserved
  • 11. SWF and HTML both stream Actually both are progressive download SWF compilers assemble the pieces so that elements can display and run when enough data has downloaded HTML page streams line by line and executes or displays © SitePen, Inc. 2009. All Rights Reserved
  • 12. Web APIs / Web Services JavaScript: XHR and JSONP XHR (XmlHttpRequest) has cross domain issues eval sends a string to the JavaScript engine to be interpreted eval(“alert(1 + 2);”); // alerts 3 Flash: XML & Remoting XML is heavy on the wire Remoting needs a server that handles it crossdomain.xml - newer browsers are supporting this © SitePen, Inc. 2009. All Rights Reserved
  • 13. Embedding the SWF In the meantime, Eolas might sue every last, lousy company in creation © SitePen, Inc. 2009. All Rights Reserved
  • 14. The bare bones embed object <object> <param name=movie value="myMovie.swf"> <embed src="myMovie.swf" /> </object> © SitePen, Inc. 2009. All Rights Reserved
  • 15. object vs. embed object for IE object node has attributes object has child nodes with more attributes embed for everyone else No child attributes Can be a child of the object node © SitePen, Inc. 2009. All Rights Reserved
  • 16. A more typical embed object <object width="480" height="270" align="middle" codebase="http://download.macromedia.com/pub/shockwave/cabs/ flash/swflash.cab#version=9,0,0,0" classid="clsid:d27cdb6e- ae6d-11cf-96b8-444553540000" name="my__player" id="my__player"> <param value="always" name="allowScriptAccess"/> <param value="true" name="allowFullScreen"/> <param value="http://flash.local/my__player.swf? prefsfile=http://flash.local/xml/prefs_skunk.xml" name="movie"/> <param value="my_movie" name="name"/> <param value="my_movie" name="id"/> <param value="high" name="quality"/> <param value="#ffffff" name="bgcolor"/> <embed width="480" height="270" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" name="my__player" bgcolor="#ffffff" quality="high" src="http://flash.local/my__player.swf? prefsfile=http://flash.local/xml/prefs_skunk.xml"/> </object> © SitePen, Inc. 2009. All Rights Reserved
  • 17. Attributing Attributes - object Root attributes width, height, align, codebase, classid, name, id Child attributes - passed to the player once it is started. allowScriptAccess, allowFullScreen, movie (src), wmode, swLiveConnect © SitePen, Inc. 2009. All Rights Reserved
  • 18. Attributing Attributes - embed Can be a root node or child of object node As a child, browser determine whther to ignore the embed tags or the object tags No embed child nodes Root attributes width, height, align, name, id, allowScriptAccess, allowFullScreen, src, wmode, pluginspage, type, swLiveConnect © SitePen, Inc. 2009. All Rights Reserved
  • 19. Solution: Dynamic embedding With thanks to that damn Eolas More control over the myriad attributes Better reusability Most attributes can be preset Sets up ExternalInterface for you Fires events for SWF readiness Bonus: SEO! © SitePen, Inc. 2009. All Rights Reserved
  • 20. Dynamic embedding libraries SWFObject dojox.embed.Flash AC_RunActiveContent.js Mike’s custom code © SitePen, Inc. 2009. All Rights Reserved
  • 21. Mike’s custom code example <body> <div align=center> <script src="mike.js" id="MIKE" config="swf=my_player,width=480,height=270" > </script> </div> </body> © SitePen, Inc. 2009. All Rights Reserved
  • 22. Mike’s custom code highlights // find where this script is attached in the dom var snode; var scripts = document.getElementsByTagName("script"); for (var i = 0; i < scripts.length; i++) { if (scripts[i].id && scripts[i].id == "MIKE") { snode = scripts[i]; break; } } // Get the variables from the config attribute in the script var configStr = snode.getAttribute("config"); var attrs = convertToAttributes(configStr); // The parent node of the script is where we insert the SWF playerdiv = snode.parentNode; playerdiv.style.width = flashArgs.width; playerdiv.style.height = flashArgs.height; © SitePen, Inc. 2009. All Rights Reserved
  • 23. Mike’s custom code the embed object var str = '<object id="'+args.id+'" name="'+args.id+'" ' + 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ' + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/ flash/swflash.cab#version=9,0,0,0" ' + 'width="'+args.width+'" height="'+args.height+'">' + '<param name="allowScriptAccess" value="'+args.asa+'" />' + '<param name="allowFullScreen" value="'+args.fs+'" />' + '<param name="movie" value="'+args.id+'" />' + '<param name="name" value="'+args.src+'" />' + '<param name="id" value="'+args.id+'" />' + '<param name="wmode" value="'+args.wmode+'" />' + '<embed src="'+args.src+'" ' + 'width="'+args.width+'" height="'+args.height+'" ' + 'name="'+args.id+'" ' + 'allowScriptAccess="'+args.asa+'" ' + 'allowFullScreen="'+args.fs+'" ' + 'wmode="'+args.wmode+'" ' + 'type="application/x-shockwave-flash" ' + 'pluginspage="http://www.macromedia.com/go/ getflashplayer" />' + '</object>'; © SitePen, Inc. 2009. All Rights Reserved
  • 24. embed and object in the same doc? Most libraries do a browser sniff and only use one or the other In my opinion this is unnecessary because: Modern browsers elegantly ignore the other tag No bytes on the wire saved The dynamic code base is more complex The browser sniffing is what adds bytes on the wire and execution time to for parsing You lose the ability for the YouTube embed © SitePen, Inc. 2009. All Rights Reserved
  • 25. Getting that movie var swfById = function (movieName){ if(document.embeds[movieName]){ return document.embeds[movieName]; } if(document[movieName]){ return doc[movieName]; } if(window[movieName]){ return window[movieName]; } if(document[movieName]){ return document[movieName]; } return null; } © SitePen, Inc. 2009. All Rights Reserved
  • 26. Getting ActionScript and JavaScript to Talk Mommy! Daddy! Stop ghting! © SitePen, Inc. 2009. All Rights Reserved
  • 27. AS / JS Communication ExternalInterface FlashVars GetVariable/SetVariable Largely deprecated for AS3 Movie properties Primarily PercentLoaded fscommand Complete with VB Script! Which thankfully died a bloody death © SitePen, Inc. 2009. All Rights Reserved
  • 28. ExternalInterface Introduced in Flash 8 after years of abusive punishment to devs, forcing them to use the fscommand And then the Flash 8 EI was coded by drunken sailors Flash 9 EI much better But you still have craziness like this patch: window.attachEvent('onunload', function() { window.__flash__removeCallback = function (instance, name) { try { if (instance) instance[name] = null; } catch ( err ) { } }; }); © SitePen, Inc. 2009. All Rights Reserved
  • 29. ExternalInterface Examples © SitePen, Inc. 2009. All Rights Reserved
  • 30. FlashVars FlashVars attribute introduced in Flash 6 although the query string was used before that and there’s little difference No complex objects without serialization - similar to sephiroth library Examples of the need for FlashVars: Dynamic creation, as in the Dojo FileUploader URLs to connect to © SitePen, Inc. 2009. All Rights Reserved
  • 31. FlashVars <object> <param name=movie value="myMovie.swf"> <param name=FlashVars value="user=Mike&score=1000"> <embed src="myMovie.swf" FlashVars="user=Mike&score=1000" /> </object> or <object> <param name=movie value="myMovie.swf?user=Mike&score=1000"> <embed src="myMovie.swf?user=Mike&score=1000" /> </object> // accessed in AS2 in _root: _root.user // accessed in AS3: var params = LoaderInfo(this.root.loaderInfo).parameters; params.user; © SitePen, Inc. 2009. All Rights Reserved
  • 32. FlashVars Examples © SitePen, Inc. 2009. All Rights Reserved
  • 33. Flash/Browser Gotchas © SitePen, Inc. 2009. All Rights Reserved
  • 34. Flash/Browser Gotchas Flash will not initialize in a node with display=”none” DOM must be "ready" before the SWF can be inserted in node - using window.onload (or something better) Watch IE6 & IE7 Memory leaks - especially when using the ExternalInterface Detecting Mouse Events outside of SWF TabIndex between a SWF and HTML is non-existent You've heard those stories of bad Java applet implementations? Flash isn't a whole lot better. © SitePen, Inc. 2009. All Rights Reserved
  • 35. Future of Flash FutureSplash ShockWaveFlash Macromedia Flash Adobe Flash Microsoft Flash © SitePen, Inc. 2009. All Rights Reserved
  • 36. Is Flash Dead? Rumors of my death have been greatly exaggerated. - Paul McCartney © SitePen, Inc. 2009. All Rights Reserved
  • 37. Open Source But then everyone will see my code and steal all of my fantastically incredible ideas! - Mike circa 2002 © SitePen, Inc. 2009. All Rights Reserved
  • 38. HSO: AS3 was a mistake - Mike circa today © SitePen, Inc. 2009. All Rights Reserved
  • 39. Q&A © SitePen, Inc. 2009. All Rights Reserved
  • 40. Thank you! © SitePen, Inc. 2009. All Rights Reserved

Hinweis der Redaktion

  1. Software engineer at SitePen, and one of the founder of the DFW user group Club AJAX. I&amp;#x2019;m an AJAX expert with a lot of experience in HTML, CSS, and Flash as well as a lot of video. I&amp;#x2019;m a dojo committer and have written and maintain several dojo components including the DEFT project that integrates Flash into Dojo AJAX components
  2. A very well run, small company with a high customer satisfaction rate. Builds exceptional web apps that other companies have trouble with. Well known in the AJAX/OS community. Makers of the Dojo Toolkit which I&amp;#x2019;ll reference in the presentation
  3. Started with HTML and CSS - Used Flash early on with Real Media in HTML and controlled everything via JS - Struggled with the Netscape IE feud - When Netscape died, focused on IE sites - suddenly a client said &amp;#x201C;this doesn&amp;#x2019;t work in FF&amp;#x201D; - starting getting into JS in depth, and discovered AJAX and Open Source - I do AJAX, AS2, AS3, and AIR&amp;#x2026; but not a Flex guy
  4. Possibly note the irony of comparing AS and JS while showing the new &amp;#x201C;brands&amp;#x201D; of each product from splash screens and popup windows
  5. EcmaScript 2: Harmony
  6. Flash can&apos;t do a jsonp call explain what it is, why it won&apos;t work without eval
  7. Note that other AJAX libraries don&amp;#x2019;t have obvious support for SWF embedding We&amp;#x2019;ll focus on the eponymously named Mike&amp;#x2019;s custom code
  8. Good time to mention that &amp;#x201C;Mike&amp;#x2019;s code&amp;#x201D; is not publicly available, but there&amp;#x2019;s a strong chance the concepts will end up in dojo, and an outside chance of it being released as Club AJAX code
  9. Technique wouldn&apos;t work in very old browsers like Netscape 6 Note the root atts ***And duplicate use of ID and name codebase and plugins page trigger the expressInstall ie tests for versions, other browser do not and would need custom detectors
  10. Note that other AJAX libraries don&amp;#x2019;t have obvious support for SWF embedding We&amp;#x2019;ll focus on the eponymously named Mike&amp;#x2019;s custom code
  11. fscommand required doc.write which was very limiting
  12. replacement for fscommand required doc.write which was very limiting comm bridge between JS and AS AS makes calls to JS and creates functions in the JS enviro for JS to call (without erroring)
  13. Mention Uploader woes
  14. The Microsoft thing&amp;#x2026; joke.
  15. Silverlight and Microsoft will kill Flash. AJAX will kill Flash. Flash isn&amp;#x2019;t going anywhere. It&amp;#x2019;s achieved incredible market penetration with its plugin, and Adobe continues to deliver on exciting technologies that AJAX apps have to wait years for. While an MS-backed Silverlight does create competition, the winner of that competition will most likely will be developers and users.
  16. The web has evolved at a blistering pace. It was only 15 years ago that it was being used for little more than research papers (remember getting drivers off of bulletin boards?), whereas today it is the de-facto application deployment platform. A key enabler of this high rate of evolutionary change is the ability of web developers to understand what others have done in order to achieve a particular outcome and to copy that technique. We have been trained nearly our whole lives to think that copying is bad, but we know at some level that this is how we learn. A web that isn&amp;#x2019;t &amp;#x201C;view source&amp;#x201D;-able isn&amp;#x2019;t &amp;#x201C;the web&amp;#x201D;. We need to come to terms with the long-term costs of lowered productivity and higher incremental costs for any platform that doesn&amp;#x2019;t preserve the &amp;#x201C;view source&amp;#x201D; capability as a default property of the platform. We&amp;#x2019;re all reaping the benefits of decisions made 15 years ago, all the while discussing new technologies that endanger that value chain without a cogent discussion of the costs and benefits. We need to think hard about this.
  17. Java-like code creates a barrier of entry - is a move away from ECMAScript which is growing in popularity and is the language that helped Flash grow - shuts out previous Flash non-OO coders - AS3 takes longer to write - WebKit proves that strict typing isn&amp;#x2019;t necessary for speed