• About WordPress
    • WordPress.org
    • Documentation
    • Learn WordPress
    • Support
    • Feedback
  • Log In
Skip to content

MonoFlauta

Indie Game Developer

Menu
  • Blog
  • Portfolio
    • Games
      • Happy Ghost Studio
      • Etermax
      • Silky Smooth Studio
      • Fun+Mono
    • Frameworks & Tools
      • Framework Goat
      • Twitch Mono Integration
      • Framework Mono
      • Narwhal Engine
    • Others
  • Store
  • About Me

Framework Mono – Controls/MobileAccelerometer.as

IconoThe MobileAccelerometer.as script will help you to know if a mobile device, with accelerometer, is turning left, right or up. It’s just a quick script that will save you time.


How to use MobileAccelerometer.as

In order to use it, you will need to have a static instance of mono in the Main.as script. Once you have that, create an instance of the script wherever you want. Then, turn on the script by calling the function turnOn. This function will recieve as parameters the tolerance in x and y before showing true, though this values are optional because it already has default ones. Once it is turned on, you will only need to check the public values called keyLeft, keyRight and keyUp to know where is it looking.

For example we can do the following:

 package
{      
      import Mono.Controls.MobileAccelerometer;
      import Mono.Mono;
      
      import flash.display.Sprite;
      import flash.utils.Dictionary;
      
      public class Main extends Sprite
      {      
            public static var mono:Mono;
            
            public var mobileAccelerometer:MobileAccelerometer;
            
            public function Main()
            {
                  mono = new Mono(stage);
                  
                  mobileAccelerometer = new MobileAccelerometer();
                  mobileAccelerometer.turnOn(0.05, 0.05);
            }
      }
}

Now we can check the values by just doing, for example, this:

 if(mobileAccelerometer.keyUp)
 {
     //it is up, do something
 }

Public Functions

  • turnOn(toleranceX:Number=0.10, toleranceY:Number=0.10):void
  • turnOff():void

Public Vars

  • keyLeft:Boolean
  • keyRight:Boolean
  • keyUp:Boolean

Private Functions

  • checkSupport():Boolean
  • updateHandler(e:AccelerometerEvent):void

Private Vars

  • _isSupported:Boolean
  • _acc1:Accelerometer
  • _turnedOn:Boolean
  • _xTolerance:Number
  • _yTolerance:Number

Powered by WordPress MonoFlauta 2025 | All Rights Reserved.

Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}