Skip to content

Instantly share code, notes, and snippets.

@marchbold
Last active December 17, 2015 22:29
Show Gist options
  • Save marchbold/5682277 to your computer and use it in GitHub Desktop.
Save marchbold/5682277 to your computer and use it in GitHub Desktop.
This is a simple example of using the compass ANE from distriqt to get compass heading updates.
/**
* __ __ __
* ____/ /_ ____/ /______ _ ___ / /_
* / __ / / ___/ __/ ___/ / __ `/ __/
* / /_/ / (__ ) / / / / / /_/ / /
* \__,_/_/____/_/ /_/ /_/\__, /_/
* / /
* \/
* http://distriqt.com
* -------------------------------------
*
* brief: Compass ANE example for initialisation, and basic usage.
* tag: distriqt.extension.compass
*
*/
package
{
public class CompassExample extends Sprite
{
public static const DEVELOPER_KEY : String = "your-dev-key";
public function CompassExample()
{
Compass.init( DEVELOPER_KEY );
if (Compass.isSupported())
{
Compass.service.addEventListener( CompassEvent.HEADING_UPDATED, headingHandler, false, 0, true );
Compass.service.register();
}
}
private function headingHandler( event:CompassEvent ):void
{
trace( event.type +":"+ event.magneticHeading+":"+ event.trueHeading+":"+ event.headingAccuracy );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment