A few people have also noted that the demo doesn’t work across different platforms even when using the same browser. While I wanted to demonstrate how Flash and HTML5 can coexist and even complement each other, it is (sadly) also a demonstration on how HTML5 is being implemented differently across browsers and operating systems. Feel free to post a comment if you know about fixes or workarounds in the JavaScript to make it work on more browsers.
The HTML5 Flash Marriage: Geolocation source
by Serge Jespers on 08. Mar, 2010 in Flash Player, html5
The HTML5 Flash Marriage: Geolocation
by Serge Jespers on 05. Mar, 2010 in Flash Player, html5
Geolocation is a good example. HTML5 is going to get a geolocation API that works just beautifully even on devices with no GPS. Flash based applications will (currently) only get access to geolocation APIs when targeting the AIR runtime on mobile. Some browsers (I only know of Firefox 3.5 on Mac and the WebKit browser on the Nexus One) already support the HTML5 geolocation API… So why not use that to get geo information into your Flash based application?
It’s actually extremely easy to do…
But first a little bit of background as to why I was looking for this functionality. I’m actually building “this demo app” that needs the geolocation in order to have the functionality I was looking for. I want this app to work in as many places as possible. With the Flash Platform I can build this for my browser and my desktop. For the Apple phone I can export it as a native app and for the Nexus One I can use the device browser with Flash Player 10.1.
Now… How does it work? The HTML5 geolocation API is extremely easy to use and, like I said earlier, you don’t even need to have a GPS enabled device.
function getGEO()
{
// First check if your browser supports the geolocation API
if (navigator.geolocation)
{
alert("HTML 5 is getting your location");
// Get the current position
navigator.geolocation.getCurrentPosition(function(position)
{
lat = position.coords.latitude
long = position.coords.longitude;
// Pass the coordinates to Flash
passGEOToSWF(lat, long);
});
} else {
alert("Sorry... your browser does not support the HTML5 GeoLocation API");
}
}
function passGEOToSWF(lat,long)
{
alert("HTML 5 is sending your location to Flash");
// Pass the coordinates to mySWF using ExternalInterface
document.getElementById("mySWF").passGEOToSWF(lat,long);
}
In my Flash application, I’m using ExternalInterface so I can communicate between JavaScript and my SWF. When my Google Maps component is ready, I call the GetGEO JavaScript method:
ExternalInterface.call("getGEO");
When the JavaScript method gets a result from the geolocation API, it will pass it on to the passGEOToSWF method. In my Flash application, I just listen for that method call and then call the code to update the map.
ExternalInterface.addCallback("passGEOToSWF", onPassGEOToSWF);
If you don’t have an HTML5 ready browser, check out this video of the application running in Firefox 3.6. Even cooler is that this also works in the browser on my Flash Player 10.1 enabled Nexus One (Please note that the network is slower on the N1 and thus it isn’t able to keep up with loading new map images. This has nothing to do with Flash Player 10.1 or the application.):
If you have Firefox 3.5 or newer installed, you can give it a try yourself: http://www.webkitchen.be/geolocation. I’m sure there are other browsers out there that also already have the geolocation API but this is the only one I tested on the Mac.
Hopefully this gives you a good idea of how HTML5 and Flash can also just work together (instead of killing each other ;-)). Flash on!
UPDATE: While writing this blog post, @robertbak pinged me on Twitter saying that he wrote a library to use in your Flex applications. Check it out on the Flex Exchange.
UPDATE: For the source files check out this blogpost.
Video tutorial: “Elf Yourself” yourself – Personalized video on the web
by Serge Jespers on 13. Nov, 2009 in How-to, Video Tutorial
Note: Please update your After Effects CS4 installation to make sure you have the latest version available via the Adobe Updater. There is an issue with the preinstalled After Effects script that requires you to work with the latest point release (separate downloads available for Mac OS and Windows).
Ever wondered how you can create personalized video on the web? Want to create your own ElfYourself.com? This tutorial shows you how it’s done using After Effects CS4 and Flash Professional CS4. Ooh.. before I forget… One of my evangelist colleagues has a cameo appearance at the end of the tutorial ;-)
Tutorial: Sexy transitions with Flex 3 (as used in the MAX widget)
by Serge Jespers on 28. Aug, 2009 in Flex, How-to
“Including the animations?“, was a question I got a lot. And yes… Even the animations are “programmed” using the Flex framework. And you know what… It’s really not as hard as it sounds. The Flex framework actually has a bunch of effects built in and they are really easy to use.
In this case, I used 2 move effects and specified a “Back.easeOut” easingFunction. This easing function creates that bouncing effect that you see in the widget.
<mx:Move id="moveIn" yFrom="400" duration="350" easingFunction="Back.easeOut"/> <mx:Move id="moveOut" yTo="400" duration="250" easingFunction="Back.easeIn"/>
You can use these types of effects in a number of different ways but the easiest way (I think) is to specify the showEffect and hideEffect on a component.
<mx:Canvas id="page1_back" showEffect="moveIn" hideEffect="moveOut" width="400" height="400"/>
When you set the visible property to false, the hideEffect will trigger and the showEffect gets triggered when you set the visible property to true. I’m sure you can already see how I built this ;-)
In the widget, you see 6 different pieces of graphics slide in to place over time. To do that, I created a timer that triggers my setup function over time.
var setupTimer:Timer = new Timer(150, 3);
setupTimer.addEventListener("timer", doSetupPage1);
setupTimer.start();
This timer will trigger the doSetupPage1 function 3 times with 150 milliseconds in between each call. All my doSetupPage1 function does, is set the visible property to true on the different pieces of graphics I want to show.
private function doSetupPage1(event:TimerEvent):void
{
switch (event.target.currentCount)
{
case 1:
page1_back.visible = true;
break;
case 2:
page1_middle.visible = true;
break
case 3:
page1_front.visible = true;
break;
}
}
To hide them, I’m actually doing exactly the same thing. Instead of setting the visible property to true, I set it to false and when all pieces of artwork are hidden, I trigger the function that reveals the next page.
[flash medium=5 w=400 h=400 mode=1]
To get you started, I created this little Flex project that demonstrates this approach. Now I’m not saying that this is best practice or not but I think it’s just an easy way to create sexy transitions with Flex 3.
Learn ActionScript 3.0 using Flash Professional CS4
by Serge Jespers on 30. Jul, 2009 in ActionScript
ActionScript 1:1 is a free training resource that combines video tutorials, documentation and sample files to teach you the basics of ActionScript 3.0 using Flash Professional CS4. The course is specifically designed for Flash designers and animators who want to add some custom interaction using ActionScript 3.0 but need a little bit of help getting started. Doug starts off with the very basics and then gradually explains more ActionScript that will make your designs and animations interactive and dynamic. He makes it very easy to understand and I’m sure you’ll be coding ActionScript 3.0 in no time.
ActionScript 1:1 is available on Adobe, through RSS and on iTunes. See Doug’s blog for the links to the videos and the sample projects.
Flash on!
Video tutorial: Use Flex for your ActionScript coding for Flash CS4
by Serge Jespers on 09. Mar, 2009 in Flash, Flex, How-to, Video, Video Tutorial
Video tutorial: Use the Flex webservice component in Flash CS4 projects
by Serge Jespers on 02. Mar, 2009 in Flash, Flex, How-to, Video, Video Tutorial
UPDATE: My sincere apologies. There is an error in my code which I did not explain in the video.
Line 10 should not read myWebService.load but myWebService.loadWSDL.
I do remember we recorded this one twice and I fear that that’s where the mixup happened. Please download the working FLA below.
Download the FLA file.
Video tutorial: Introduction to Adobe’s mobile platform
by Serge Jespers on 18. Feb, 2009 in How-to, Popular, Video, Video Tutorial, mobile
I’ve recorded a little video that walks you through the process and will be doing more videos on how to build mobile applications soon.
Video tutorial: Create Flex container components with Flash CS4
by Serge Jespers on 11. Feb, 2009 in Flash, Flex, How-to, Popular, Video, Video Tutorial
The Flex Component Kit for Flash is incredibly powerful and allows you to combine your Flash design/development skills with the power of the Flex framework.
Subscribe to the Adobe Developer Connection videos on iTunes.
How to use the new Text Layout Framework
by Serge Jespers on 19. Jan, 2009 in How-to
My colleague Mihai Corlan just published an excellent article on how to use the new Text Layout Framework.
The Text Layout Framework (released on Labs) is an extensible library, built on the new text engine in Adobe Flash Player 10 (and also available in AIR 1.5), which delivers advanced, easy-to-integrate typographic and text layout features for rich, sophisticated and innovative typography on the web.
Go check it out on Mihai’s blog.
- Robert Scoble interviews Flash Platform execs 11. Mar, 2010
- Number 1 on my wishlist: HP’s slate device 08. Mar, 2010
- The HTML5 Flash Marriage: Geolocation source 08. Mar, 2010
- The HTML5 Flash Marriage: Geolocation 05. Mar, 2010
- The MWC 2010 Flash Challenge 04. Mar, 2010
Latest Tweets
Where am I?
Serge Jespers is at home in Mechelen, Belgium.
Flash Platform blogs
- Adam Lehman
- AIR team blog
- Andrew Shorten
- Ben Forta
- Christian Cantrell
- Christophe Coenraets
- Duane Nickull
- Enrique Duvos
- Ethan Malasky
- Flash Platform blog
- Greg Wilson
- James Ward
- Kevin Hoyt
- Lee Brimelow
- Mark Doherty
- Matt Chotin
- Mihai Corlan
- Mike Chambers
- Piotr Walczyszyn
- Renaun Erickson
- Ryan Stewart
- Ted Patrick
- Terry Ryan
- Tom Krcha







