Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.events.GeolocationEvent;
- import flash.sensors.Geolocation;
- import flash.display.MovieClip;
- import flash.text.TextField;
- import flash.events.TimerEvent;
- import flash.display.*;
- public class MainClass extends MovieClip {
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////
- // textfields
- private var lat_txt:TextField = new TextField();
- private var long_txt:TextField = new TextField();
- private var accuracy_txt:TextField = new TextField();
- private var feedback_txt:TextField = new TextField();
- private var badgePosNumber:Array = new Array;
- // custom classes
- private var starBadges:Badges;
- private var sInactive:starInactive;
- private var sActive:starActive;
- // position data
- public var totalDistance:Number = new Number(1000); // user defines later.
- public var lapStop:Number = new Number(5); // user defines later.
- public var badgeCount:Number;
- public var movedDistance:Number = new Number(500); // user defines later.
- public var pLeft:Number = 60;
- // arrays
- public var inActiveLocation:Array = new Array; // .x location for inactive badge
- public var inactiveA:Array = new Array; // inactive badges to array
- //
- public var activeLocationA:Array = new Array; // .x location for active badge
- public var activeA:Array = new Array; // active badges to array
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////
- public function MainClass()
- {
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.align = StageAlign.TOP;
- getLapStops();
- initGPS();
- }
- public function getLapStops():void
- {
- var badgeCount = new Number;
- for (var i = 0; i < lapStop; i++)
- {
- badgeCount = (totalDistance / lapStop);
- badgeCount += i * (badgeCount);
- badgePosNumber.push(badgeCount);
- }
- badgePosNumber.toString([1]);
- checkActiveStars();
- //initGPS();
- }
- public function initGPS():void
- {
- if (!Geolocation.isSupported)
- {
- var geo:Geolocation = new Geolocation();
- geo = new Geolocation();
- geo.setRequestedUpdateInterval(50);
- geo.addEventListener(GeolocationEvent.UPDATE,geolocationUpdateHandler);
- for (var i = 0; i < 5; i++)
- {
- sInactive = new starInactive();
- stage.addChild(sInactive);
- sInactive.y = 315;
- sInactive.x = pLeft + i * (20 + sInactive.width);
- inActiveLocation.push(sInactive.x);
- trace('Inactive star added at ||' + sInactive.x);
- trace('inActiveLocation values ' + inActiveLocation);
- inactiveA.push(sInactive[0]);
- trace(inActiveLocation[2]);
- }
- }
- else
- {
- feedback_txt.text = "Seems like Geolocation isnt supported.";
- trace(feedback_txt.text);
- }
- checkActiveStars();
- }
- public function geolocationUpdateHandler(event:GeolocationEvent):void
- {
- lat_txt.text = "Latitude: " + event.latitude;
- long_txt.text = "Longtitude: " + event.longitude;
- accuracy_txt.text = "Horizontal Accuracy: " + event.horizontalAccuracy;
- addChild(lat_txt);
- }
- public function checkActiveStars():void
- {
- sActive = new starActive;
- if(badgePosNumber[0] <= movedDistance)
- {
- trace("moved distance is greater than badgePosNumber " + badgePosNumber[0]);
- addChild(sActive.push;
- sActive.y = 315;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement