views:

217

answers:

1

I want to pass Value from Constructor in my Main Class to another Class.

Main Class:

public function Main() {

  Snap.locationX = 350;
 }

Another Class:

   public function get locationX():Number{
      return _value;
   }


   public function set locationX(x:Number):void{
      _value = x;   
   }

It returns 1061: Call to a possibly undefined method locationX through a reference with static type Class.

What am I doing wrong?

A: 

The setter and getter methods you have defined above are INSTANCE methods. It seems like you are calling Snap.locationX on the Snap class itself and not on an instance of the Snap class.

try (under Main()):

var snapObj:Snap = new Snap();
snapObj.locationX = ...
Lior Cohen
Thanks. You wouldn't believe how many times I've got caught on instance methods. cheers
dd