{"id":1216,"date":"2015-02-05T14:40:04","date_gmt":"2015-02-05T13:40:04","guid":{"rendered":"http:\/\/www.aymericlamboley.fr\/blog\/?p=1216"},"modified":"2015-02-05T15:07:35","modified_gmt":"2015-02-05T14:07:35","slug":"geophysic-making-air-shine-thanks-to-feathers","status":"publish","type":"post","link":"http:\/\/www.aymericlamboley.fr\/blog\/geophysic-making-air-shine-thanks-to-feathers\/","title":{"rendered":"Geophysic, making AIR shine thanks to Feathers"},"content":{"rendered":"<p><em>Update: The project has been <a href=\"http:\/\/www.thefwa.com\/mobile\/jaeger-lecoultre-geophysic\" target=\"_blank\">FWA mobile of the day<\/a>! Note that this blog post was written 3 months before its publication.<\/em><\/p>\n<p>This new project was kind of special for me, I made an iPad application, <a href=\"https:\/\/itunes.apple.com\/us\/app\/geophysic\/id928353438?mt=8\" target=\"_blank\">Geophysic\u00ae<\/a> with one of the best French agency <a href=\"http:\/\/www.soleilnoir.net\/\" target=\"_blank\">Soleil Noir<\/a> for the famous luxary watches <a href=\"http:\/\/www.jaeger-lecoultre.com\" target=\"_blank\">Jaeger-LeCoultre<\/a>. No less!<br \/>\nWhen I was a student, Soleil Noir was the best French agency and we all dreamed to work there! So you could imagine how fun it was to work with them! As a luxury brand, Jaeger-LeCoultre, has a very high expectation of the final product. Combined with Soleil Noir&#8217;s graphic designers, it results in a top quality iPad application.<\/p>\n<p><!--more--><\/p>\n<p><a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2014\/10\/screen480x480.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2014\/10\/screen480x480-300x225.jpg\" alt=\"screen480x480\" width=\"300\" height=\"225\" class=\"alignleft size-medium wp-image-1228\" srcset=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2014\/10\/screen480x480-300x225.jpg 300w, http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2014\/10\/screen480x480.jpg 480w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><strong>Going Native or AIR?<\/strong><br \/>\nObviously my first choice concerning Geophysic\u00ae was the technology. The client wanted only an iPad application, so no cross-platform needed at all. As I read the specs, my intuition was to go for pure Objective-C, but as I went down the list, I had doubts.<\/p>\n<p>There were multi-languages support (English, French, Spanish, German, Chinese and Japanese) via an XML with HTML support for multiple-fonts, exponent, links, multi-color text etc. There was also leading, letter spacing on typography, dynamic text field background color, etc. We must have scrolling functionality controlling exactly the position (it wasn&#8217;t always a screen sized), parallax, complex animations and deep video support.<\/p>\n<p>Without any doubt, I was more comfortable with AIR so I took this road and I never regretted it at all!<\/p>\n<p><a href=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2014\/10\/screen480x480-1.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2014\/10\/screen480x480-1-300x225.jpg\" alt=\"screen480x480-1\" width=\"300\" height=\"225\" class=\"alignleft size-medium wp-image-1231\" srcset=\"http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2014\/10\/screen480x480-1-300x225.jpg 300w, http:\/\/www.aymericlamboley.fr\/blog\/wp-content\/uploads\/2014\/10\/screen480x480-1.jpg 480w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><strong>Feathers<\/strong><br \/>\nThe client expected the app to be blazing fast. So I used Stage3D via <a href=\"http:\/\/starling-framework.org\/\" target=\"_blank\">Starling<\/a>. The complex part was on all the UI: slider, list, scrolling text, panel, screen scrolling etc. Since several years I followed <a href=\"http:\/\/feathersui.com\/\" target=\"_blank\">Feathers<\/a> which is a Starling library for UI inspired by iOS default one. I already used it a bit for <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/alef-is-out\/\" target=\"_blank\">Alef<\/a>, for list, but I didn&#8217;t like its API. Anyway I knew it was the way to go.<\/p>\n<p>Feathers is not easy to get started with : complex API, the factory design pattern everywhere, some properties don&#8217;t provide IDE&#8217;s auto-completion etc. But mother of god, it works, <strong>it just work like a charm<\/strong>. All the default behavior clone perfectly iOS one, and we may change parameters in no time. So kudos Josh! Also thanks to be so open-minded, asking for feedbacks, discussing your API choices&#8230;!<\/p>\n<p>I used Feathers 2, performances are awesome. I may scroll at 60 FPS a long chapter having 14000px height (on an iPad 3 retina) with many scrollable text, parallax on images, fullscreen slideshow etc.<\/p>\n<p><strong>Flash TextField<\/strong><br \/>\nFlash has always been a great tool to display text. Ok, I know it has always been crazy with <em>defaultTextFormat<\/em>, <em>setTextFormat<\/em>&#8230; but in terms of features which other technology can compete? And with its html support you may combine fonts change, color, size etc. However Starling doesn&#8217;t use Flash TextField and so there isn&#8217;t html support. It doesn&#8217;t matter, Feathers may use native Flash Textfield: it creates the TextField, turns it into a texture and upload it onto the GPU for using with Starling. Performances are awesome! Full htmlText support and we may also use leading and letter spacing. I know doing this via Objective-C and Xcode is a crazy nightmare. Flash, you (still) rock!<\/p>\n<p>We&#8217;ve also added support to link in html with many paragraph and the ability to draw quad behind letters (see slideshow caption). It was complex to parse the <em>htmlText<\/em> since <em>textfield.text<\/em> doesn&#8217;t include this information. Have a look on the <a href=\"https:\/\/github.com\/DaVikingCode\/TextFieldTextRenderer-extended\" target=\"_blank\">extension we made<\/a> for Feather&#8217;s TextFieldTextRenderer class.<\/p>\n<p><strong>Animations<\/strong><br \/>\nIf you give a look to the Chapter 1, you will encounter a nice animation on the family tree. It is interactive. That would have been another complex thing to do with Objective-C. We use Flash Pro to create components with familty tree informations and position them on a MovieClip. Then we export a SWC. At runtime we parse the SWC and create the according textures. That was a quick process, I wouldn&#8217;t imagine to do that with Objective-C.<\/p>\n<p>Also on the Chapter 3, we used <a href=\"https:\/\/github.com\/StarlingGraphics\/Starling-Extension-Graphics\" target=\"_blank\">Starling-Extension-Graphics<\/a> to create donuts-like and make them grow at runtime. Sure it could be done in Objective-C but it&#8217;s way faster to do that in Flash.<\/p>\n<p><strong>Transitions<\/strong><br \/>\nI used my beloved <a href=\"http:\/\/citrusengine.com\/\" target=\"_blank\">Citrus Engine<\/a> for all the state process, sounds etc. Something really complex was to have smooth transitions between chapters. When you know chapter size you know that you won&#8217;t be able to have two chapters at the same time and make a quick transition. So I used like a &#8220;cache&#8221; system:<\/p>\n<pre lang=\"actionscript3\">\/\/we draw our screen content into a bitmap data\r\nvar bmpd:BitmapData = stage.drawToBitmapData(null, false);\r\nvar texture:Texture = Texture.fromBitmapData(bmpd, false, false, _ce.scaleFactor);\r\nvar img:Image = new Image(texture);\r\n\r\nStarling.current.stage.addChild(img);\r\n\r\n_ce.state = newChapter; \/\/the previous state is automatically garbaged thanks to the Citrus Engine\r\nnewChapter.x = stage.stageWidth;\r\n\r\n\/\/ waiting upload\r\neaze(this).delay(2.25).onComplete(function():void {\r\n\teaze(img).to(1, {x:-Starling.current.stage.stageWidth}).easing(Expo.easeInOut);\r\n\r\n\tTweenLite.to(_ce.state, 1, {x:0, ease:ExpoInOut.ease, onComplete:function():void {\r\n\t\ttexture.dispose();\r\n\t\tStarling.current.stage.removeChild(img, true);\r\n\t\tbmpd.dispose();\r\n\t}});\r\n});<\/pre>\n<p><strong>Video ANE<\/strong><br \/>\nThe big deal of this application coded with AIR was videos. I had to display video with content above. Also in the last Chapter, there are several videos running at the same time. Now let&#8217;s have a look on what AS3 offer concerning video:<\/p>\n<ul>\n<li>Flash display list Video object is not efficient.<\/li>\n<li>StageVideo may not have any things related to Starling on top of it and may only have 1 Video playing (on mobile).<\/li>\n<li>Using an HTML wrapper would be really inefficient.<\/li>\n<li><a href=\"https:\/\/forums.adobe.com\/message\/6615256\" target=\"_blank\">VideoTexture<\/a> is still not available on mobile.<\/li>\n<\/ul>\n<p>Dammit! VideoTexture would be the perfect solution but it isn&#8217;t available on mobile at the moment. So? Let&#8217;s go native thanks to AIR Native Extension! Have a look on my <a href=\"https:\/\/github.com\/DaVikingCode\/Video-ANE\" target=\"_blank\">Video ANE<\/a>. Displaying video on Objective-C side gives me awesome performances! However since Objective-C is on top of Flash I can&#8217;t put any AS3 object on my video. So I coded a whole part in the ANE for giving bitmapdata from Flash to Objective-C to create an image and even display animations in Objective-C. Then being able to remove them etc. That was quite funny \ud83d\ude09<br \/>\nObviously this part would have been done faster if the whole project was in Objective-C, but without any doubt I did the project way faster with AIR than if I used Objective-C.<\/p>\n<p><strong>AIR shine and other tech?<\/strong><br \/>\nI&#8217;m really happy to use AIR daily. Once we will have the VideoTexture and workers (for concurrency on iOS) features I don&#8217;t see anything missing to AIR &#038; Starling with Feathers. And when you know the whole project runs fine on Android (except the video native stuff), desktop and web, you don&#8217;t look back to native.<\/p>\n<p>And you what do you think ? Which other tech could have done <a href=\"https:\/\/itunes.apple.com\/us\/app\/geophysic\/id928353438?mt=8\" target=\"_blank\">this app<\/a> without pain? Xamarin?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: The project has been FWA mobile of the day! Note that this blog post was written 3 months before its publication. This new project was kind of special for me, I made an iPad application, Geophysic\u00ae with one of the best French agency Soleil Noir for the famous luxary watches Jaeger-LeCoultre. No less! When &hellip; <a href=\"http:\/\/www.aymericlamboley.fr\/blog\/geophysic-making-air-shine-thanks-to-feathers\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Geophysic, making AIR shine thanks to Feathers<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[161,4,51,177,33,98,90],"tags":[119,15,50,178,99,91],"_links":{"self":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/1216"}],"collection":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/comments?post=1216"}],"version-history":[{"count":21,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/1216\/revisions"}],"predecessor-version":[{"id":1431,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/posts\/1216\/revisions\/1431"}],"wp:attachment":[{"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/media?parent=1216"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/categories?post=1216"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.aymericlamboley.fr\/blog\/wp-json\/wp\/v2\/tags?post=1216"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}