Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8829113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:45:38+00:00 2026-06-14T07:45:38+00:00

I am testing out the accelerometer and I tried using the default AIR for

  • 0

I am testing out the accelerometer and I tried using the default AIR for Android example and am now trying to make my own game in flash. I copied off of the example’s code:

    import flash.events.Event;

var accelX:Number;
var accelY:Number;

var fl_Accelerometer:Accelerometer = new Accelerometer();
fl_Accelerometer.addEventListener(AccelerometerEvent.UPDATE, fl_AccelerometerUpdateHandler);
function fl_AccelerometerUpdateHandler(event:AccelerometerEvent):void
{
    accelX = event.accelerationX;
    accelY = event.accelerationY;
}

ball.addEventListener(Event.ENTER_FRAME, moveBall);
function moveBall(evt:Event){
    ball.x -= accelX*30;
    ball.y += accelY*30;

    if(ball.x > (480-ball.width/2)){
        ball.x = 480-ball.width/2;
    }
    if(ball.x < (0+ball.width/2)){
        ball.x = 0+ball.width/2;
    }
    if(ball.y > (800-ball.width/2)){
       ball.y = 800-ball.width/2;
    }
    if(ball.y < (0+ball.width/2)){
        ball.y = 0+ball.width/2;
    }

I keep on getting this error:

Scene 1, Layer 'actions', Frame 1, Line 6   1046: Type was not found or was not a compile-time constant: Accelerometer.
Scene 1, Layer 'actions', Frame 1, Line 6   1180: Call to a possibly undefined method Accelerometer.

I know I am making a huge novice error but I would really appreciate some help, thank you for who ever took the time to read this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:45:40+00:00Added an answer on June 14, 2026 at 7:45 am

    You need to import the Accelerometer class: import flash.sensors.Accelerometer.
    Be sure to publish as Android Air project!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm testing out my CSS at http://flexibletheme.tumblr.com/ and trying to make the website responsive
Newbie using mongo 2.0.1 32-bit on windows tried testing out shards as follows: (4)
I was testing out an interface I built using jQuery UI draggable, droppable and
Im testing out some database compact code using a simple form to add data
I am currently testing out using OSGi. I am running this through Eclipse. I
I am testing out the simple pong game found here: https://github.com/shangaslammi/frp-pong The problem is
I'm testing out the PostgreSQL Text-Search features, using the September data dump from StackOverflow
I have been testing out using delegates instead of reflection for some object sorting
I'm testing out using memcached to cache django views. How can I tell if
I am testing out using ADAM and the DSML services. I have two ADAM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.