Contents
- Usage
- Using the Library
- Using the Themes
- Using the Demo App
- Components
- Accordion
- AnimatedImage
- AutoComplete
- AutoFitText
- BarCode
- BitmapAdjustments
- ButtonBar
- Calculator
- Calendar
- CAPTCHA
- CarouselLayout
- CarouselList
- Clocks
- Colorizer
- ColorPicker
- ColorSpacePicker
- CompassContainer
- CoverflowLayout
- CoverflowList
- CursorManager
- DatePicker
- DockingCompassContainer
- Donut Chart
- ExpandingContainer
- FieldSet
- Filters
- FlexContextMenu
- FloatPaneControlBar
- Funnel Chart
- GraphicsEditor
- Heatmap
- HtmlDragDrop
- HtmlFrame
- HtmlGeolocation
- iCalendarParser
- iCalendarRecurrence
- IconButton
- Linear Gauges
- Magnifier
- Menu and MenuBar
- MiniViewport
- PackedLayout
- PackedList
- Pane
- PopUpButton
- ProgressDisplay
- Radar
- Radial Gauge
- Rating
- ReflectionContainer
- RichTextEditor
- RotaryField
- SafariMouseWheelFix
- Scroller
- Separators
- SliderField
- Sparklines
- TabPaneNavigator
- TextInput
- TimebarContainer
- Timeline
- TimeMachineLayout
- TimeMachineList
- TimePicker
- ToggleSwitchDesktop
- TransformContainer
- TreeMap
- ViewStack
- WheelList
HtmlGeolocation
Overview
The Geolocation component uses the HTML5 API of modern browsers to retrieve the user's geographic location.
AIR
This component will NOT work within the AIR environment. For HTML support in AIR, try the native mx.controls.HTML and flash.html.HTMLLoader classes.
Requirements
Only works if the browser supports HTML5 geolocation and ExternalInterface.
Flash Geolocation
Flash has both Geolocation and GeolocationEvent classes for mobile devices with location sensors. This class brings some of that functionality to desktop based applications.
Creating the HtmlGeolocation Component
The component is not visual and is not added to the display list. Extends EventDispatcher and should either be declared in the <fx:Declarations> tag or in Actionscript.
Using the HtmlGeolocation Component
Attach an UPDATE and ERROR listener and call getCurrentPosition() to retrieve the user location. Since the location data is returned asynchronously, an event handler is required to get the location data. See the events in the htmlGeolocation package for the information returned by the update and error events.
Security
To test in the local domain, on the "preinitialize" event, add the following code to the "preinitialize" event handler:
Security.allowDomain("*");
Even with the above code, this component may fail in local testing in some browsers.
Note that users can deny access to their location if desired. Notice of rejection is available via the error event.
Example
<htmlGeolocation:HtmlGeolocation id="htmlGeolocation"> error="Alert.show(event.errorType, 'ERROR', 4, this, null, null, 0, moduleFactory);" update="geolocation_updateHandler(event)" </htmlGeolocation:HtmlGeolocation>
See the HtmlGeolocation application for more example code.
Known Bugs
Firefox 4+: if the user does not allow location tracking by selecting "Not Now" to the permission prompt, it will not fire the errorHandler, so the developer will not get an indication of failure. Plan accordingly. May be a good idea to set a timeout handler.
Custom Events
UPDATE
ardisia.components.htmlGeolocation.events.HtmlGeolocationEvent
Dispatched when the ExternalInterface returns position data after a call to
getCurrentPosition().
ERROR
ardisia.components.htmlGeolocation.events.HtmlGeolocationEvent
Dispatched when the ExternalInterface returns an error after a call to
getCurrentPosition().