# Class constructor event occurs before variables are passed in?

**URL:** <https://forum.kirupa.com/t/class-constructor-event-occurs-before-variables-are-passed-in/310720>\
**Category:** flash\
**Created:** [June 17, 2010, 2:34pm UTC](https://forum.kirupa.com/t/class-constructor-event-occurs-before-variables-are-passed-in/310720 "2010-06-17T14:34:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitShifter\_](https://avatars.discourse-cdn.com/v4/letter/b/e99b99/32.png) [@bitShifter\_](https://forum.kirupa.com/u/bitShifter_)\
**Post date:** [June 17, 2010, 2:34pm UTC](https://forum.kirupa.com/t/class-constructor-event-occurs-before-variables-are-passed-in/310720/1 "2010-06-17T14:34:51Z")

</div>

Hey guys. 🙂

I’m having a little trouble with my move to as3, (surprise surprise huh?) 😉

Basically when I create a movieclip, I wan’t to pass some values into it, like so:

```auto

var menu=new Menu();
menu.x=50;
addChild(menu);

```

That seems okay, right? But the problem is, when I trace out x in the constructor of the new object, it’s still zero… However onEnterFrame it becomes 50 (as it should). So how do I access the new variable right away?

```auto

function Menu(){
            addEventListener(Event.ENTER_FRAME,step);
            trace(this.x);
        }
        
        function step(e){
            trace(x);
        }

```

Any help would be much appreciated ☹
