Class constructor event occurs before variables are passed in?

Hey guys. :slight_smile:

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

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


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?


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

Any help would be much appreciated :frowning: