# AS3: Graphic based speedometer for driving game

**URL:** <https://forum.kirupa.com/t/as3-graphic-based-speedometer-for-driving-game/321541>\
**Category:** programming\
**Created:** [April 22, 2011, 12:25pm UTC](https://forum.kirupa.com/t/as3-graphic-based-speedometer-for-driving-game/321541 "2011-04-22T12:25:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iakona](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@Iakona](https://forum.kirupa.com/u/Iakona)\
**Post date:** [April 22, 2011, 12:25pm UTC](https://forum.kirupa.com/t/as3-graphic-based-speedometer-for-driving-game/321541/1 "2011-04-22T12:25:30Z")

</div>

Hi there!

I’m currently making a simple racing game in AS3… I’m not all that expierenced with games as this is only my second one.

Right now i have a dynamic text based speedometer that works as it should… The numbers in the textfield increases/decrease depending on the speed of the car. However i would like to create a proper one.(PICTURE BELOW)

I have a basic understanding of how it works… I know the “needle” would be a movieclip and would rotate round… But i’m not sure how to make this relate to the speed variable.

Code for my dynmaic text speedo…

> 

// constants  
static const maxSpeed:Number = .5;  
static const accel:Number = .0002;  
static const decel:Number = .0002;  
static const turnSpeed:Number = .25;

```
    // game variables
    private var arrowLeft,arrowRight,arrowUp,arrowDown:Boolean;
    private var lastTime:int;
    private var gameStartTime:int;
    private var speed:Number;

```

speedo.text = String(speed \* 150);  
if (speed \< 0)  
{  
speedo.text = String(0);  
}

![](http://forum.kirupa.com/uploads/kirupa/6515/8e645423c616eda1.jpg)
