# Const vs. var at compile time?

**URL:** <https://forum.kirupa.com/t/const-vs-var-at-compile-time/319384>\
**Category:** Uncategorized\
**Created:** [February 18, 2011, 2:34pm UTC](https://forum.kirupa.com/t/const-vs-var-at-compile-time/319384 "2011-02-18T14:34:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![activa](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@activa](https://forum.kirupa.com/u/activa)\
**Post date:** [February 18, 2011, 2:34pm UTC](https://forum.kirupa.com/t/const-vs-var-at-compile-time/319384/1 "2011-02-18T14:34:38Z")

</div>

I want to calculate the width of a MC and create a constant so that I can accurately figure out where to place it on the stage. So I create a new instance of the clip and assign the value of the width to a variable:

var Temp:MovieClip = new TempClip;  
var TempWidth:Number = Temp.width;

which works fine, but if I initialize it as a constant:

var Temp:MovieClip = new TempClip;  
const TEMP\_WIDTH:Number = Temp.width;

I get a “null value” error. So I guess it’s something to do with when the compiler sets the values?
