ExternalInterface
class. In this post, I adopted the geolocation W3C specification and implemented an ActionScript class to wrap the Gears and Geode javascript functions so they can be invoked from a Flex application. Make sure to install Gears and/or Geode to test this application. Using FlexBuilder, the index.template.html
has to be adjusted to include the gears_init.js
file and the geolocation.js
wrapper file as follows:
...
<script type="text/javascript" src="AC_OETags.js"></script>
<script type="text/javascript" src="gears_init.js"></script>
<script type="text/javascript" src="geolocation.js"></script>
<style>
...
The registration of the callback functions is done by creating an instance of the GeoLocation class:
...
<geolocation:GeoLocation id="geolocation"/>
...
The position of the web application can be determined using something of the form:
...
geolocation.getCurrentPosition( currentPositionSuccessHandler, currentPositionFaultHandler );
...
Check out the application here. And like usual, you can download the source from here.
No comments:
Post a Comment